結果

問題 No.5 数字のブロック
ユーザー ぴろずぴろず
提出日時 2014-12-21 01:04:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 289 ms / 5,000 ms
コード長 481 bytes
コンパイル時間 3,292 ms
コンパイル使用メモリ 74,780 KB
実行使用メモリ 47,456 KB
最終ジャッジ日時 2024-04-29 00:32:52
合計ジャッジ時間 10,806 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
41,420 KB
testcase_01 AC 136 ms
41,120 KB
testcase_02 AC 146 ms
41,252 KB
testcase_03 AC 256 ms
46,736 KB
testcase_04 AC 233 ms
45,316 KB
testcase_05 AC 265 ms
46,344 KB
testcase_06 AC 273 ms
45,780 KB
testcase_07 AC 250 ms
45,816 KB
testcase_08 AC 243 ms
45,808 KB
testcase_09 AC 209 ms
43,472 KB
testcase_10 AC 269 ms
46,868 KB
testcase_11 AC 232 ms
45,692 KB
testcase_12 AC 265 ms
46,420 KB
testcase_13 AC 276 ms
46,788 KB
testcase_14 AC 171 ms
41,396 KB
testcase_15 AC 189 ms
41,804 KB
testcase_16 AC 283 ms
46,228 KB
testcase_17 AC 286 ms
47,216 KB
testcase_18 AC 289 ms
47,256 KB
testcase_19 AC 284 ms
47,456 KB
testcase_20 AC 118 ms
40,176 KB
testcase_21 AC 134 ms
41,356 KB
testcase_22 AC 130 ms
41,204 KB
testcase_23 AC 135 ms
41,408 KB
testcase_24 AC 193 ms
41,716 KB
testcase_25 AC 190 ms
42,012 KB
testcase_26 AC 131 ms
40,984 KB
testcase_27 AC 140 ms
41,260 KB
testcase_28 AC 142 ms
41,048 KB
testcase_29 AC 232 ms
45,416 KB
testcase_30 AC 216 ms
43,592 KB
testcase_31 AC 136 ms
41,444 KB
testcase_32 AC 133 ms
41,136 KB
testcase_33 AC 133 ms
40,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no005;

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

public class Main {

	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 ans = 0;
		int sum = 0;
		for(int i=0;i<n;i++) {
			sum += w[i];
			if (sum > l) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(n);
	}

}
0