結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2018-11-21 22:39:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 607 bytes |
| コンパイル時間 | 1,995 ms |
| コンパイル使用メモリ | 74,140 KB |
| 実行使用メモリ | 47,992 KB |
| 最終ジャッジ日時 | 2024-12-24 16:06:32 |
| 合計ジャッジ時間 | 9,940 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 34 |
ソースコード
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int L = sc.nextInt();
int N = sc.nextInt();
int[] W = new int[N];
for(int i = 0; i < N; i++)
W[i] = sc.nextInt();
Arrays.sort(W);
int sum = 0;
int ans = 0;
for(int i = 0; i < N; i++) {
sum += W[i];
if(sum <= L)
i++;
}
System.out.println(ans);
}
}