티스토리 뷰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
1 <= d.length <= 100
1 <= d.val <= 100,000
1 <= budget <= 10,000,000
돈을 정확하게 줘야함.
몇개의 부서에 지원할수있는지 최댓값
*/
import java.util.Arrays;
public class Level1_예산 {
public static int solution(int[] d, int budget) {
int ans = 0;
Arrays.sort(d);
for (int j : d) {
if (budget < j) {
return ans;
}
budget -= j;
ans++;
}
return ans;
}
public static void main(String[] args) {
int[] d = {2,2,3,3};
int budget = 10;
int ans = solution(d, budget);
System.out.println(ans);
}
}
|
cs |
'PS > programmers' 카테고리의 다른 글
Level1) 비밀지도 (0) | 2021.03.17 |
---|---|
Level1) 실패율 (0) | 2021.03.16 |
Level2) 전화번호 목록 (0) | 2021.01.08 |
Level2)가장 큰 수 (0) | 2020.11.10 |
Level2) 기능개발 (0) | 2020.11.10 |
링크
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- http
- BOJ
- js api
- 프로그래머스 SQL
- 김영한 JPA
- REST API
- 김영한 http
- GCP
- 프로그래머스
- HTTP 완벽가이드
- 킹수빈닷컴
- java
- 이펙티브자바
- dreamcoding
- 이펙티브자바 아이템59
- 백준
- Spring Security
- 백기선 스터디
- HTTP 완벽 가이드
- js array
- 모던자바스크립트
- JPA 연관관계 매핑
- 패스트캠퍼스 컴퓨터공학 완주반
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- 드림코딩
- 이펙티브자바 스터디
- js promise
- JS 딥다이브
- 이펙티브자바 아이템60
- ㅇㄷㅇㅈ
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함