結果

問題 No.5 数字のブロック
ユーザー papipenpapipen
提出日時 2017-03-26 14:51:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 48,032 KB
最終ジャッジ日時 2024-04-29 08:54:04
合計ジャッジ時間 9,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,656 KB
testcase_01 AC 105 ms
41,808 KB
testcase_02 AC 125 ms
40,220 KB
testcase_03 AC 230 ms
47,272 KB
testcase_04 AC 204 ms
46,328 KB
testcase_05 AC 258 ms
48,008 KB
testcase_06 AC 218 ms
46,688 KB
testcase_07 AC 212 ms
45,884 KB
testcase_08 AC 245 ms
47,432 KB
testcase_09 AC 199 ms
44,060 KB
testcase_10 AC 248 ms
47,840 KB
testcase_11 AC 227 ms
46,404 KB
testcase_12 AC 247 ms
47,808 KB
testcase_13 AC 233 ms
48,032 KB
testcase_14 AC 139 ms
42,292 KB
testcase_15 AC 144 ms
42,096 KB
testcase_16 AC 243 ms
47,672 KB
testcase_17 AC 254 ms
47,964 KB
testcase_18 AC 268 ms
47,888 KB
testcase_19 AC 279 ms
48,020 KB
testcase_20 AC 131 ms
41,464 KB
testcase_21 AC 137 ms
41,988 KB
testcase_22 AC 132 ms
41,880 KB
testcase_23 AC 124 ms
42,008 KB
testcase_24 AC 150 ms
42,420 KB
testcase_25 AC 185 ms
42,652 KB
testcase_26 AC 131 ms
41,528 KB
testcase_27 AC 130 ms
41,344 KB
testcase_28 AC 131 ms
41,592 KB
testcase_29 AC 234 ms
46,232 KB
testcase_30 AC 215 ms
44,020 KB
testcase_31 AC 131 ms
41,536 KB
testcase_32 AC 132 ms
41,508 KB
testcase_33 AC 132 ms
41,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Block{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		int L = s.nextInt();
		int N = s.nextInt();
		int W[] = new int[N];
		for(int i = 0; i < N; i++){
			W[i] = s.nextInt();
		}
		Arrays.sort(W);
		
		int sum = 0;
		for(int j = 0; j < N; j++){
			sum += W[j];
			if(sum == L){
				System.out.println(j + 1);
				System.exit(0);
			}else if(sum > L){
				System.out.println(j);
				System.exit(0);
			}
		}
		System.out.println(N);
	}
}
0