結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2016-05-22 16:26:12 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 598 ms / 2,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 76,992 KB |
実行使用メモリ | 46,164 KB |
最終ジャッジ日時 | 2024-07-05 15:50:38 |
合計ジャッジ時間 | 9,357 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import java.util.*; class No0156{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int cnt = 0; ArrayList<Integer> ar = new ArrayList<Integer>(); for(int i = 0; i < n; i++){ ar.add(sc.nextInt()); } for(int i = 0; i < m; i++){ Collections.sort(ar); for(int j = 0; j < ar.size(); j++){ if(ar.get(j) > 0){ ar.set(j, ar.get(j) - 1); break; } } } for(int i = 0; i < ar.size(); i++){ if(ar.get(i) == 0){ cnt++; } } System.out.println(cnt); } }