結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-03 13:12:53 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 164 ms / 5,000 ms |
| コード長 | 589 bytes |
| 記録 | |
| コンパイル時間 | 2,360 ms |
| コンパイル使用メモリ | 83,992 KB |
| 実行使用メモリ | 51,152 KB |
| 最終ジャッジ日時 | 2026-05-12 21:09:36 |
| 合計ジャッジ時間 | 7,220 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int n = sc.nextInt();
List<Integer> w = new ArrayList<Integer>();
for(int i=0; i<n; i++){
w.add(sc.nextInt());
}
sc.close();
Collections.sort(w);
int sum = 0;
int count;
for(count = 0; count<w.size(); count++){
if(l >= sum + w.get(count)){
sum = sum + w.get(count);
}else{
break;
}
}
System.out.println(count);
}
}