結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-06-12 15:33:21 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 652 bytes |
| 記録 | |
| コンパイル時間 | 2,656 ms |
| コンパイル使用メモリ | 82,804 KB |
| 実行使用メモリ | 50,800 KB |
| 最終ジャッジ日時 | 2026-04-27 00:45:47 |
| 合計ジャッジ時間 | 6,921 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int box = sc.nextInt();
int count = sc.nextInt();
ArrayList<Integer> boxlist = new ArrayList<Integer>();
for(int i=0;i<count;i++){
int input = sc.nextInt();
boxlist.add(input);
}
sc.close();
Collections.sort(boxlist);
int total=0;
int result = 0;
for(int k=0;box>total&&boxlist.size()>k;k++){
total += boxlist.get(k);
if(box>total){
result++;
}else{
break;
}
}
System.out.println(result);
}// mainmethod
} // class