結果

問題 No.5 数字のブロック
ユーザー AoiroFukurouAoiroFukurou
提出日時 2016-05-19 14:21:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 275 ms / 5,000 ms
コード長 539 bytes
コンパイル時間 3,431 ms
コンパイル使用メモリ 75,296 KB
実行使用メモリ 47,872 KB
最終ジャッジ日時 2024-04-29 07:16:32
合計ジャッジ時間 11,014 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,336 KB
testcase_01 AC 130 ms
41,204 KB
testcase_02 AC 120 ms
40,336 KB
testcase_03 AC 242 ms
46,340 KB
testcase_04 AC 220 ms
45,672 KB
testcase_05 AC 257 ms
46,988 KB
testcase_06 AC 232 ms
46,540 KB
testcase_07 AC 218 ms
45,900 KB
testcase_08 AC 242 ms
46,284 KB
testcase_09 AC 199 ms
43,468 KB
testcase_10 AC 254 ms
47,380 KB
testcase_11 AC 231 ms
45,836 KB
testcase_12 AC 245 ms
46,692 KB
testcase_13 AC 258 ms
46,620 KB
testcase_14 AC 149 ms
41,396 KB
testcase_15 AC 157 ms
41,440 KB
testcase_16 AC 263 ms
46,644 KB
testcase_17 AC 271 ms
47,872 KB
testcase_18 AC 270 ms
46,432 KB
testcase_19 AC 275 ms
47,712 KB
testcase_20 AC 128 ms
41,092 KB
testcase_21 AC 118 ms
40,336 KB
testcase_22 AC 127 ms
41,176 KB
testcase_23 AC 114 ms
39,816 KB
testcase_24 AC 156 ms
41,524 KB
testcase_25 AC 186 ms
41,692 KB
testcase_26 AC 132 ms
41,232 KB
testcase_27 AC 135 ms
41,088 KB
testcase_28 AC 132 ms
41,512 KB
testcase_29 AC 233 ms
45,612 KB
testcase_30 AC 217 ms
43,512 KB
testcase_31 AC 128 ms
41,428 KB
testcase_32 AC 118 ms
40,168 KB
testcase_33 AC 126 ms
41,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

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

public class No5v2 {
	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 tmp = 0;
		int c = 0;
		for (int i = 0; i < w.length; i++) {
			w[i] = sc.nextInt();
		}
		Arrays.sort(w);//ソート
		
		for (int i = 0; i < w.length; i++) {
			if (L - tmp >= w[i]) {
				tmp += w[i];
				c++;
			} else {
				break;
			}
		}
		System.out.println(c);
		sc.close();
	}
}
0