結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
40,196 KB
testcase_01 AC 135 ms
41,252 KB
testcase_02 AC 132 ms
41,216 KB
testcase_03 AC 252 ms
46,560 KB
testcase_04 AC 229 ms
45,648 KB
testcase_05 AC 266 ms
47,100 KB
testcase_06 AC 245 ms
45,900 KB
testcase_07 AC 236 ms
45,460 KB
testcase_08 AC 252 ms
46,944 KB
testcase_09 AC 205 ms
43,312 KB
testcase_10 AC 257 ms
47,444 KB
testcase_11 AC 229 ms
45,932 KB
testcase_12 AC 251 ms
46,444 KB
testcase_13 AC 262 ms
47,296 KB
testcase_14 AC 148 ms
41,272 KB
testcase_15 AC 163 ms
41,540 KB
testcase_16 AC 265 ms
46,296 KB
testcase_17 AC 276 ms
47,416 KB
testcase_18 AC 279 ms
47,508 KB
testcase_19 AC 274 ms
47,508 KB
testcase_20 AC 134 ms
41,020 KB
testcase_21 AC 133 ms
41,240 KB
testcase_22 AC 135 ms
40,900 KB
testcase_23 AC 131 ms
41,640 KB
testcase_24 AC 168 ms
42,120 KB
testcase_25 AC 188 ms
42,120 KB
testcase_26 AC 134 ms
41,336 KB
testcase_27 AC 120 ms
40,308 KB
testcase_28 AC 133 ms
41,112 KB
testcase_29 AC 226 ms
45,600 KB
testcase_30 AC 211 ms
43,520 KB
testcase_31 AC 135 ms
41,236 KB
testcase_32 AC 132 ms
41,320 KB
testcase_33 AC 131 ms
41,088 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 n : w) {
			if (L - tmp >= n) {
				tmp += n;
				c++;
			} else {
				break;
			}
		}
		System.out.println(c);
	}
}
0