結果

問題 No.5 数字のブロック
ユーザー AoiroFukurouAoiroFukurou
提出日時 2016-05-19 14:23:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 275 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 4,136 ms
コンパイル使用メモリ 74,460 KB
実行使用メモリ 47,812 KB
最終ジャッジ日時 2024-04-29 07:18:52
合計ジャッジ時間 10,953 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
40,124 KB
testcase_01 AC 131 ms
41,308 KB
testcase_02 AC 132 ms
41,080 KB
testcase_03 AC 241 ms
46,204 KB
testcase_04 AC 225 ms
45,644 KB
testcase_05 AC 259 ms
47,020 KB
testcase_06 AC 234 ms
46,084 KB
testcase_07 AC 229 ms
45,444 KB
testcase_08 AC 243 ms
46,556 KB
testcase_09 AC 205 ms
43,680 KB
testcase_10 AC 257 ms
47,436 KB
testcase_11 AC 228 ms
45,540 KB
testcase_12 AC 242 ms
46,160 KB
testcase_13 AC 260 ms
47,128 KB
testcase_14 AC 144 ms
41,564 KB
testcase_15 AC 151 ms
41,568 KB
testcase_16 AC 258 ms
45,928 KB
testcase_17 AC 268 ms
47,812 KB
testcase_18 AC 262 ms
47,788 KB
testcase_19 AC 275 ms
47,476 KB
testcase_20 AC 129 ms
41,192 KB
testcase_21 AC 128 ms
41,220 KB
testcase_22 AC 130 ms
41,316 KB
testcase_23 AC 130 ms
41,168 KB
testcase_24 AC 159 ms
41,576 KB
testcase_25 AC 179 ms
41,960 KB
testcase_26 AC 117 ms
40,008 KB
testcase_27 AC 130 ms
41,144 KB
testcase_28 AC 129 ms
41,144 KB
testcase_29 AC 222 ms
46,024 KB
testcase_30 AC 206 ms
43,768 KB
testcase_31 AC 130 ms
41,136 KB
testcase_32 AC 117 ms
39,964 KB
testcase_33 AC 130 ms
41,312 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();
		}
		sc.close();
		
		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);
	}
}
0