結果

問題 No.5 数字のブロック
ユーザー ぴろずぴろず
提出日時 2014-12-21 01:04:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 277 ms / 5,000 ms
コード長 481 bytes
コンパイル時間 5,856 ms
コンパイル使用メモリ 72,008 KB
実行使用メモリ 60,772 KB
最終ジャッジ日時 2023-08-11 07:56:03
合計ジャッジ時間 11,019 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,516 KB
testcase_01 AC 128 ms
55,484 KB
testcase_02 AC 130 ms
55,724 KB
testcase_03 AC 239 ms
59,800 KB
testcase_04 AC 224 ms
59,336 KB
testcase_05 AC 251 ms
59,668 KB
testcase_06 AC 238 ms
60,292 KB
testcase_07 AC 221 ms
59,240 KB
testcase_08 AC 241 ms
59,732 KB
testcase_09 AC 203 ms
58,532 KB
testcase_10 AC 258 ms
60,096 KB
testcase_11 AC 228 ms
59,856 KB
testcase_12 AC 247 ms
60,396 KB
testcase_13 AC 253 ms
60,448 KB
testcase_14 AC 145 ms
55,504 KB
testcase_15 AC 159 ms
56,004 KB
testcase_16 AC 262 ms
60,568 KB
testcase_17 AC 263 ms
60,672 KB
testcase_18 AC 265 ms
60,772 KB
testcase_19 AC 277 ms
60,220 KB
testcase_20 AC 130 ms
55,572 KB
testcase_21 AC 129 ms
55,496 KB
testcase_22 AC 131 ms
55,532 KB
testcase_23 AC 130 ms
55,488 KB
testcase_24 AC 157 ms
55,936 KB
testcase_25 AC 187 ms
56,288 KB
testcase_26 AC 129 ms
55,976 KB
testcase_27 AC 128 ms
56,068 KB
testcase_28 AC 131 ms
55,796 KB
testcase_29 AC 222 ms
59,060 KB
testcase_30 AC 199 ms
58,336 KB
testcase_31 AC 128 ms
55,516 KB
testcase_32 AC 132 ms
56,016 KB
testcase_33 AC 131 ms
55,680 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