結果

問題 No.5 数字のブロック
ユーザー marumaru
提出日時 2016-03-20 03:00:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 549 ms / 5,000 ms
コード長 909 bytes
コンパイル時間 3,319 ms
コンパイル使用メモリ 77,088 KB
実行使用メモリ 43,752 KB
最終ジャッジ日時 2024-04-29 07:04:01
合計ジャッジ時間 11,671 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
41,240 KB
testcase_01 AC 122 ms
41,696 KB
testcase_02 AC 122 ms
41,588 KB
testcase_03 AC 258 ms
42,516 KB
testcase_04 AC 244 ms
41,896 KB
testcase_05 AC 381 ms
42,972 KB
testcase_06 AC 246 ms
42,672 KB
testcase_07 AC 244 ms
42,652 KB
testcase_08 AC 283 ms
42,596 KB
testcase_09 AC 161 ms
40,948 KB
testcase_10 AC 400 ms
43,752 KB
testcase_11 AC 203 ms
42,080 KB
testcase_12 AC 283 ms
42,756 KB
testcase_13 AC 398 ms
43,096 KB
testcase_14 AC 126 ms
41,144 KB
testcase_15 AC 127 ms
41,536 KB
testcase_16 AC 392 ms
43,088 KB
testcase_17 AC 489 ms
43,356 KB
testcase_18 AC 366 ms
43,056 KB
testcase_19 AC 549 ms
43,664 KB
testcase_20 AC 109 ms
41,000 KB
testcase_21 AC 107 ms
41,024 KB
testcase_22 AC 117 ms
41,512 KB
testcase_23 AC 98 ms
40,128 KB
testcase_24 AC 119 ms
41,084 KB
testcase_25 AC 134 ms
40,280 KB
testcase_26 AC 124 ms
40,932 KB
testcase_27 AC 104 ms
40,248 KB
testcase_28 AC 100 ms
40,696 KB
testcase_29 AC 214 ms
41,132 KB
testcase_30 AC 160 ms
41,344 KB
testcase_31 AC 96 ms
41,096 KB
testcase_32 AC 106 ms
40,912 KB
testcase_33 AC 114 ms
40,868 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