結果

問題 No.5 数字のブロック
ユーザー ajukinkinajukinkin
提出日時 2016-07-07 15:52:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,225 bytes
コンパイル時間 3,785 ms
コンパイル使用メモリ 75,496 KB
実行使用メモリ 50,604 KB
最終ジャッジ日時 2024-04-21 00:48:10
合計ジャッジ時間 7,125 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
37,284 KB
testcase_01 AC 53 ms
37,140 KB
testcase_02 WA -
testcase_03 AC 96 ms
39,300 KB
testcase_04 AC 73 ms
38,196 KB
testcase_05 AC 101 ms
39,480 KB
testcase_06 AC 90 ms
38,900 KB
testcase_07 AC 85 ms
38,456 KB
testcase_08 AC 94 ms
39,236 KB
testcase_09 AC 59 ms
37,096 KB
testcase_10 AC 100 ms
39,912 KB
testcase_11 AC 77 ms
38,612 KB
testcase_12 AC 84 ms
39,756 KB
testcase_13 AC 99 ms
40,436 KB
testcase_14 AC 51 ms
37,056 KB
testcase_15 AC 53 ms
36,948 KB
testcase_16 AC 100 ms
40,296 KB
testcase_17 AC 103 ms
40,160 KB
testcase_18 AC 105 ms
40,172 KB
testcase_19 AC 95 ms
40,660 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 50 ms
37,328 KB
testcase_24 AC 52 ms
37,156 KB
testcase_25 AC 54 ms
37,128 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 78 ms
38,624 KB
testcase_30 AC 61 ms
37,400 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = 0; // 箱の個数
      for (int i = 0; i < strBoxWidths.length; i++) {
          if (width + boxWidths[i] > boxLength) {
            boxNum = i;
            break;
          }
          width += boxWidths[i];
      }
      
      // 結果出力
      System.out.println(boxNum);
    } catch (Throwable th) {
      th.printStackTrace();
    }
   }
}
0