結果

問題 No.5 数字のブロック
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 10:23:17
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 632 bytes
コンパイル時間 5,290 ms
コンパイル使用メモリ 71,972 KB
実行使用メモリ 60,544 KB
最終ジャッジ日時 2023-09-20 19:21:27
合計ジャッジ時間 14,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,876 KB
testcase_01 AC 121 ms
55,624 KB
testcase_02 RE -
testcase_03 AC 382 ms
59,860 KB
testcase_04 AC 286 ms
60,476 KB
testcase_05 AC 442 ms
60,168 KB
testcase_06 AC 344 ms
60,164 KB
testcase_07 AC 306 ms
60,168 KB
testcase_08 AC 356 ms
60,116 KB
testcase_09 AC 226 ms
59,192 KB
testcase_10 AC 455 ms
60,300 KB
testcase_11 AC 310 ms
60,072 KB
testcase_12 AC 386 ms
59,904 KB
testcase_13 AC 426 ms
57,928 KB
testcase_14 AC 133 ms
55,632 KB
testcase_15 AC 158 ms
55,968 KB
testcase_16 AC 473 ms
60,324 KB
testcase_17 AC 529 ms
60,120 KB
testcase_18 AC 482 ms
60,544 KB
testcase_19 AC 603 ms
59,896 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 135 ms
55,724 KB
testcase_24 AC 168 ms
56,052 KB
testcase_25 AC 204 ms
56,000 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 306 ms
60,148 KB
testcase_30 AC 255 ms
58,340 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No5 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt(); //箱の幅
		int N = sc.nextInt(); //ブロックの数
		int W[] = new int[N]; //各ブロックの幅
		int x;
		int sum = 0;
		int count;
		
		for(int i = 0;i < N;i++) {
			W[i] = sc.nextInt();
		}
		
		for(int i = 0;i < N;i++) { //Wを昇順にソート
			for(int j = i + 1;j < N;j++) {
				if(W[i] > W[j]) {
					x = W[i];
					W[i] = W[j];
					W[j] = x;
				}
			}
		}
		
		for(count = 0;sum <= L;count++) {
			sum += W[count];
		}
		
		System.out.println(count - 1);
	}
}
0