結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
Democo
|
| 提出日時 | 2015-05-02 00:49:47 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 258 ms / 5,000 ms |
| コード長 | 442 bytes |
| コンパイル時間 | 1,864 ms |
| コンパイル使用メモリ | 74,180 KB |
| 実行使用メモリ | 58,908 KB |
| 最終ジャッジ日時 | 2024-11-17 22:41:37 |
| 合計ジャッジ時間 | 8,817 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.*;
class Yukico5 {
public static void main(String[] args){
Scanner stdin = new Scanner(System.in);
int l = stdin.nextInt();
int n = stdin.nextInt();
int[] w = new int[n];
for(int i=0; i<n; i++) {
w[i] = stdin.nextInt();
}
Arrays.sort(w);
int a=0;
int i=0;
while(a<=l && i<n) {
a = a+w[i];
i++;
}
if(i==n && a<=l) {
System.out.println(i);
} else {
System.out.println(i-1);
}
}
}
Democo