結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
|
提出日時 | 2018-01-18 23:31:47 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 3,440 ms |
コンパイル使用メモリ | 74,816 KB |
実行使用メモリ | 37,360 KB |
最終ジャッジ日時 | 2024-07-05 16:12:15 |
合計ジャッジ時間 | 6,027 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
package me.yukicoder.lv1; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class No0156 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String[] s1 = br.readLine().split(" "); String[] s2 = br.readLine().split(" "); int N = Integer.parseInt(s1[0]); int M = Integer.parseInt(s1[1]); int[] candy = new int[N]; int cntBox = 0; for (int i = 0; i < N; i++) { candy[i] = Integer.parseInt(s2[i]); } Arrays.sort(candy); for (int i = 0; i < N; i++) { M -= candy[i]; if(M < 0) { break; } cntBox++; } System.out.println(cntBox); } catch (IOException e) { e.printStackTrace(); } } }