結果

問題 No.5 数字のブロック
ユーザー marumaru
提出日時 2016-03-20 03:00:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 556 ms / 5,000 ms
コード長 909 bytes
コンパイル時間 4,142 ms
コンパイル使用メモリ 74,540 KB
実行使用メモリ 61,300 KB
最終ジャッジ日時 2023-08-11 14:50:47
合計ジャッジ時間 13,204 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,720 KB
testcase_01 AC 121 ms
55,692 KB
testcase_02 AC 120 ms
55,568 KB
testcase_03 AC 344 ms
57,184 KB
testcase_04 AC 255 ms
55,420 KB
testcase_05 AC 431 ms
56,980 KB
testcase_06 AC 297 ms
57,460 KB
testcase_07 AC 272 ms
57,360 KB
testcase_08 AC 325 ms
57,236 KB
testcase_09 AC 171 ms
55,932 KB
testcase_10 AC 453 ms
57,012 KB
testcase_11 AC 252 ms
56,984 KB
testcase_12 AC 336 ms
57,168 KB
testcase_13 AC 394 ms
57,388 KB
testcase_14 AC 119 ms
55,732 KB
testcase_15 AC 123 ms
55,584 KB
testcase_16 AC 438 ms
57,236 KB
testcase_17 AC 516 ms
57,052 KB
testcase_18 AC 471 ms
57,160 KB
testcase_19 AC 556 ms
61,300 KB
testcase_20 AC 118 ms
55,644 KB
testcase_21 AC 115 ms
55,824 KB
testcase_22 AC 114 ms
55,624 KB
testcase_23 AC 114 ms
57,752 KB
testcase_24 AC 129 ms
55,816 KB
testcase_25 AC 137 ms
56,100 KB
testcase_26 AC 115 ms
55,632 KB
testcase_27 AC 116 ms
55,768 KB
testcase_28 AC 114 ms
55,784 KB
testcase_29 AC 231 ms
55,660 KB
testcase_30 AC 174 ms
55,832 KB
testcase_31 AC 117 ms
56,028 KB
testcase_32 AC 115 ms
55,968 KB
testcase_33 AC 113 ms
55,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class yukicoder_5 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		String str_l = scanner.nextLine();
		int l = Integer.parseInt(str_l);
		
		String str_n = scanner.nextLine();
		int n = Integer.parseInt(str_n);
		
		String w = scanner.nextLine();
		
		String[] array = w.split(" ");
		int[] array2 = new int[array.length];
		
		for (int i = 0; i < array.length; i++) {
			array2[i] = Integer.parseInt(array[i]);
		}
		
		for (int j = 0; j < array2.length; j++) {
			for (int i = 0; i < array2.length - 1; i++) {
				if (array2[i] > array2[i+1]) {
					int t;
					t = array2[i];
					array2[i] = array2[i+1];
					array2[i+1] = t;
				}
			}
		}
		
		int count = 0;
		int sum = 0;
		
		for (count = 0; count < array2.length; count++) {
			sum += array2[count];
			
			if (sum > l) break;
		}
		
		System.out.println(count);
	}
}
	
0