結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
aikon_marimo
|
| 提出日時 | 2018-01-30 00:15:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 120 ms / 2,000 ms |
| コード長 | 508 bytes |
| コンパイル時間 | 1,893 ms |
| コンパイル使用メモリ | 75,056 KB |
| 実行使用メモリ | 41,456 KB |
| 最終ジャッジ日時 | 2024-07-05 16:12:30 |
| 合計ジャッジ時間 | 6,532 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
package yukicoder.No156;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N, M;
List<Integer> arrC = new ArrayList<Integer>();
N = in.nextInt();
M = in.nextInt();
for (int i = 0; i < N; i++) {
int C = in.nextInt();
arrC.add(C);
}
Collections.sort(arrC);
int cnt = 0;
int sum = 0;
while (M > 0) {
M -= arrC.get(cnt++);
}
if (M < 0) {
cnt = cnt-1;
}
System.out.println(cnt);
}
}
aikon_marimo