結果
問題 | No.5 数字のブロック |
ユーザー | aparachia14 |
提出日時 | 2016-01-13 23:45:19 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,805 bytes |
コンパイル時間 | 3,849 ms |
コンパイル使用メモリ | 76,172 KB |
実行使用メモリ | 56,016 KB |
最終ジャッジ日時 | 2023-10-19 23:00:09 |
合計ジャッジ時間 | 7,923 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
53,520 KB |
testcase_01 | AC | 54 ms
53,520 KB |
testcase_02 | WA | - |
testcase_03 | AC | 112 ms
55,288 KB |
testcase_04 | AC | 100 ms
55,180 KB |
testcase_05 | WA | - |
testcase_06 | AC | 111 ms
55,540 KB |
testcase_07 | AC | 99 ms
55,296 KB |
testcase_08 | AC | 111 ms
55,304 KB |
testcase_09 | AC | 90 ms
54,628 KB |
testcase_10 | AC | 120 ms
55,424 KB |
testcase_11 | AC | 96 ms
55,008 KB |
testcase_12 | AC | 112 ms
55,120 KB |
testcase_13 | AC | 117 ms
55,432 KB |
testcase_14 | AC | 56 ms
52,508 KB |
testcase_15 | WA | - |
testcase_16 | AC | 125 ms
55,864 KB |
testcase_17 | AC | 134 ms
55,944 KB |
testcase_18 | AC | 129 ms
55,912 KB |
testcase_19 | AC | 132 ms
56,016 KB |
testcase_20 | AC | 55 ms
53,508 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 56 ms
53,504 KB |
testcase_24 | AC | 57 ms
53,528 KB |
testcase_25 | AC | 62 ms
53,540 KB |
testcase_26 | AC | 56 ms
53,504 KB |
testcase_27 | AC | 55 ms
53,512 KB |
testcase_28 | AC | 55 ms
53,384 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 55 ms
53,440 KB |
testcase_32 | AC | 56 ms
53,436 KB |
testcase_33 | AC | 56 ms
53,456 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; //No.5数字のブロック public class NumberBlock { public static void main(String[] args) throws IOException { // TODO 自動生成されたメソッド・スタブ //大きな箱の幅 int widthOfBox; //ブロックの数 int numberOfBlock; //各ブロックの幅 ArrayList<Integer> widthOfBlock = new ArrayList<Integer>(); //入力値の取得 BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); widthOfBox = Integer.parseInt(in.readLine()); numberOfBlock = Integer.parseInt(in.readLine()); String[] temp = in.readLine().split(" "); //tempをバラし、int型に直しwidthOfBoxに格納する。 for(String width : temp){ widthOfBlock.add(Integer.parseInt(width)); } //ArrayListから最小値を求め、その値をwidthOfBoxから減算し、その後ArrayListからその値を除外する。 //この処理をwidthOfBoxの値が0以下になるまで繰り返す。 int min;//最小値格納変数 int counter; //カウンタ int counter2 = 0;//第二カウンタ int index = 0;//削除対象要素番号格納変数 int capacity = widthOfBox; while(true){ min = widthOfBox; counter = 0; //配列から最小値を求める。 for(int width2 : widthOfBlock){ if(min > width2){//width2の方がminより値が小さければminに格納 min = width2; index = counter;//削除対象の要素番号を記憶 }else{ } counter++; } if(capacity - min > 0){ capacity = capacity - min; counter2++; }else{ break; } widthOfBlock.remove(index);//ArrayListから削除 } System.out.println(counter2); } }