結果

問題 No.5 数字のブロック
ユーザー kano_townkano_town
提出日時 2014-11-21 19:15:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 288 ms / 5,000 ms
コード長 456 bytes
コンパイル時間 3,522 ms
コンパイル使用メモリ 75,096 KB
実行使用メモリ 47,688 KB
最終ジャッジ日時 2024-04-29 00:33:10
合計ジャッジ時間 11,595 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
41,624 KB
testcase_01 AC 139 ms
41,532 KB
testcase_02 AC 142 ms
41,532 KB
testcase_03 AC 243 ms
47,200 KB
testcase_04 AC 229 ms
45,656 KB
testcase_05 AC 271 ms
46,992 KB
testcase_06 AC 253 ms
46,276 KB
testcase_07 AC 239 ms
46,136 KB
testcase_08 AC 268 ms
46,140 KB
testcase_09 AC 242 ms
43,660 KB
testcase_10 AC 288 ms
47,268 KB
testcase_11 AC 238 ms
45,676 KB
testcase_12 AC 259 ms
46,900 KB
testcase_13 AC 272 ms
46,748 KB
testcase_14 AC 152 ms
41,936 KB
testcase_15 AC 164 ms
42,000 KB
testcase_16 AC 264 ms
46,432 KB
testcase_17 AC 282 ms
47,688 KB
testcase_18 AC 278 ms
47,484 KB
testcase_19 AC 284 ms
47,680 KB
testcase_20 AC 138 ms
41,312 KB
testcase_21 AC 142 ms
41,924 KB
testcase_22 AC 143 ms
41,168 KB
testcase_23 AC 143 ms
41,588 KB
testcase_24 AC 165 ms
41,540 KB
testcase_25 AC 189 ms
42,300 KB
testcase_26 AC 135 ms
41,420 KB
testcase_27 AC 138 ms
41,700 KB
testcase_28 AC 140 ms
41,204 KB
testcase_29 AC 239 ms
45,860 KB
testcase_30 AC 217 ms
43,856 KB
testcase_31 AC 134 ms
41,072 KB
testcase_32 AC 135 ms
41,108 KB
testcase_33 AC 135 ms
41,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Yukicoder05 {

	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];
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		Arrays.sort(W);
		
		int i, sum = 0;
		for (i = 0; i < N; i++) {
			sum += W[i];
			if (sum > L) break;
		}
		System.out.println(i);
	}
}
0