Submission #124170

#TimeUsernameProblemLanguageResultExecution timeMemory
124170KhalilBenGamraIce Hockey World Championship (CEOI15_bobek)Java
0 / 100
94 ms9988 KiB
import java.util.Arrays; import java.util.Scanner; class Main { public static void main (String[] args){ Scanner scan = new Scanner(System.in); int nb = scan.nextInt(); int budget = scan.nextInt(); int[] prices = new int[nb]; for (int i = 0; i < prices.length; i++) { prices[i] = scan.nextInt(); } Arrays.sort(prices); int count = 1; for (int i = 0; i < prices.length; i++) { if(prices[i]>budget)break; int totalPrice = 0; for (int j = i; j < prices.length; j++) { if((totalPrice + prices[j]) > budget) { if(prices[j] == prices[j-1])count++; break; } else { count++; totalPrice += prices[j]; } } } System.out.println(count); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...