Search

์„์‹œ์œค

2.๋ฌธ์ œ์ด๋ฆ„
3. ์ˆ˜ํ–‰์‹œ๊ฐ„[์ดˆ(s)]
420
์ข‹์•„์š” ๋ˆ„๋ฅด๊ธฐ
์ข‹์•„์š” ์ˆ˜
: 0
5 more properties
| ์ฝ”๋“œ ์ž‘์„ฑํ•˜๊ธฐ
import java.util.Arrays; public class PG_12982 { // ์˜ˆ์‚ฐ static int solution(int[] amounts, int budget) { int count = 0; Arrays.sort(amounts); for (int amount : amounts) { if (amount > budget) { break; } budget -= amount; count++; } return count; } public static void main(String[] args) { int[] amounts1 = {1, 3, 2, 5, 4}; int budget1 = 9; int[] amounts2 = {2, 2, 3, 3}; int budget2 = 10; System.out.println(solution(amounts1, budget1)); System.out.println(solution(amounts2, budget2)); } }
Java
๋ณต์‚ฌ
| ์ฝ”๋“œ ์„ค๋ช…ํ•˜๊ธฐ