結果

問題 No.5 数字のブロック
ユーザー YamaKasaYamaKasa
提出日時 2018-04-19 15:39:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 281 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 74,948 KB
実行使用メモリ 47,668 KB
最終ジャッジ日時 2024-04-29 09:45:38
合計ジャッジ時間 10,100 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,328 KB
testcase_01 AC 134 ms
41,296 KB
testcase_02 AC 117 ms
40,172 KB
testcase_03 AC 239 ms
46,016 KB
testcase_04 AC 230 ms
45,712 KB
testcase_05 AC 265 ms
47,284 KB
testcase_06 AC 240 ms
45,992 KB
testcase_07 AC 229 ms
45,536 KB
testcase_08 AC 245 ms
46,952 KB
testcase_09 AC 199 ms
43,760 KB
testcase_10 AC 257 ms
47,556 KB
testcase_11 AC 223 ms
45,744 KB
testcase_12 AC 256 ms
46,508 KB
testcase_13 AC 254 ms
47,016 KB
testcase_14 AC 143 ms
41,268 KB
testcase_15 AC 158 ms
41,424 KB
testcase_16 AC 257 ms
46,392 KB
testcase_17 AC 281 ms
47,248 KB
testcase_18 AC 279 ms
47,668 KB
testcase_19 AC 278 ms
47,416 KB
testcase_20 AC 134 ms
40,952 KB
testcase_21 AC 116 ms
39,932 KB
testcase_22 AC 132 ms
41,548 KB
testcase_23 AC 135 ms
41,352 KB
testcase_24 AC 158 ms
41,568 KB
testcase_25 AC 176 ms
42,016 KB
testcase_26 AC 131 ms
41,344 KB
testcase_27 AC 116 ms
40,192 KB
testcase_28 AC 114 ms
40,124 KB
testcase_29 AC 222 ms
45,512 KB
testcase_30 AC 206 ms
43,348 KB
testcase_31 AC 131 ms
41,452 KB
testcase_32 AC 134 ms
41,184 KB
testcase_33 AC 132 ms
41,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		//System.out.println("箱の幅");
		Scanner scanner = new Scanner(System.in);
		int L = scanner.nextInt();
		//System.out.println("ブロックの数");
		int N = scanner.nextInt();
		//System.out.println("各ブロックの幅");
		int[] n = new int[N];	//ブロック
		for(int i = 0; i < N; i++) {
			n[i] = scanner.nextInt();
		}
		scanner.close();
//		BubbleSort bs = new  BubbleSort(n);
//		n = bs.getArrayAsc();
		Arrays.sort(n);
		int k = 0;	//各ブロックを合わせた幅
		int j = 0;	//while文の制御
		for(int i = 0; i < N; i++) {
			k += n[i];
			if(k <= L) {
				j++;
			}else {
				break;
			}
		}
		System.out.println(j);
		//System.out.println(k);
	}
}
0