結果
問題 | No.5 数字のブロック |
ユーザー | ajukinkin |
提出日時 | 2016-07-07 16:02:52 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 97 ms / 5,000 ms |
コード長 | 1,227 bytes |
コンパイル時間 | 4,514 ms |
コンパイル使用メモリ | 72,192 KB |
実行使用メモリ | 53,124 KB |
最終ジャッジ日時 | 2023-08-11 15:15:25 |
合計ジャッジ時間 | 6,771 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,176 KB |
testcase_01 | AC | 45 ms
49,284 KB |
testcase_02 | AC | 43 ms
49,280 KB |
testcase_03 | AC | 78 ms
52,712 KB |
testcase_04 | AC | 65 ms
51,316 KB |
testcase_05 | AC | 89 ms
52,888 KB |
testcase_06 | AC | 76 ms
52,152 KB |
testcase_07 | AC | 67 ms
51,360 KB |
testcase_08 | AC | 87 ms
53,124 KB |
testcase_09 | AC | 57 ms
50,148 KB |
testcase_10 | AC | 80 ms
52,264 KB |
testcase_11 | AC | 68 ms
51,484 KB |
testcase_12 | AC | 77 ms
52,396 KB |
testcase_13 | AC | 89 ms
52,500 KB |
testcase_14 | AC | 46 ms
49,216 KB |
testcase_15 | AC | 47 ms
49,536 KB |
testcase_16 | AC | 82 ms
52,648 KB |
testcase_17 | AC | 94 ms
52,652 KB |
testcase_18 | AC | 84 ms
52,768 KB |
testcase_19 | AC | 97 ms
52,836 KB |
testcase_20 | AC | 45 ms
49,504 KB |
testcase_21 | AC | 45 ms
49,388 KB |
testcase_22 | AC | 44 ms
49,204 KB |
testcase_23 | AC | 43 ms
49,252 KB |
testcase_24 | AC | 47 ms
49,404 KB |
testcase_25 | AC | 49 ms
49,212 KB |
testcase_26 | AC | 44 ms
49,120 KB |
testcase_27 | AC | 43 ms
49,120 KB |
testcase_28 | AC | 43 ms
49,116 KB |
testcase_29 | AC | 63 ms
49,320 KB |
testcase_30 | AC | 57 ms
50,392 KB |
testcase_31 | AC | 44 ms
49,628 KB |
testcase_32 | AC | 44 ms
49,708 KB |
testcase_33 | AC | 44 ms
49,188 KB |
ソースコード
import java.io.*; import java.util.Arrays; public class Main01 { public static void main(String[] args) { try { InputStreamReader inputStreamReader = new InputStreamReader(System.in); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String strBoxLength = bufferedReader.readLine(); int boxLength = Integer.parseInt(strBoxLength); String strBlockNum = bufferedReader.readLine(); int blockNum = Integer.parseInt(strBlockNum); String strBoxsWidth = bufferedReader.readLine(); String[] strBoxWidths = strBoxsWidth.split(" "); int[] boxWidths = new int[strBoxWidths.length]; for (int i = 0; i < blockNum; i++) { boxWidths[i] = Integer.parseInt(strBoxWidths[i]); } // ソート Arrays.sort(boxWidths); int width = 0; // 幅 int boxNum = 1; // 箱の個数 for (int i = 0; i < strBoxWidths.length; i++) { if (width + boxWidths[i] > boxLength) { break; } boxNum = i + 1; width += boxWidths[i]; } // 結果出力 System.out.println(boxNum); } catch (Throwable th) { th.printStackTrace(); } } }