結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
bigbear90560
|
| 提出日時 | 2015-07-02 21:00:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 820 bytes |
| コンパイル時間 | 3,495 ms |
| コンパイル使用メモリ | 74,652 KB |
| 実行使用メモリ | 48,452 KB |
| 最終ジャッジ日時 | 2024-07-07 22:22:02 |
| 合計ジャッジ時間 | 9,691 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
/**
* No.5 数字のブロック
*/
public class NumberBlock {
public static void main(String[] args) {
// 標準入力から読み込む際に、Scannerオブジェクトを使う。
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(); // 幅
int b = sc.nextInt(); // ブロック数
int[] c = new int[b];
for (int i=0;i<b;i++) {
c[i] = sc.nextInt(); // ブロック幅
}
// 配列をソート
Arrays.sort(c);
int resWidth = 0;
int resCount = 0;
for (int n : c) {
resWidth += n;
if (a <= resWidth) {
break;
} else {
resCount++;
}
}
System.out.println(resCount);
}
}
bigbear90560