結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
bigbear90560
|
| 提出日時 | 2015-07-03 00:42:31 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 821 bytes |
| コンパイル時間 | 3,296 ms |
| コンパイル使用メモリ | 74,560 KB |
| 実行使用メモリ | 59,000 KB |
| 最終ジャッジ日時 | 2024-07-07 22:33:36 |
| 合計ジャッジ時間 | 9,339 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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