結果

問題 No.5 数字のブロック
ユーザー ぴろずぴろず
提出日時 2014-12-21 00:54:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 4,808 ms
コンパイル使用メモリ 71,056 KB
実行使用メモリ 60,920 KB
最終ジャッジ日時 2023-09-02 20:28:49
合計ジャッジ時間 12,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,684 KB
testcase_01 AC 123 ms
55,472 KB
testcase_02 WA -
testcase_03 AC 222 ms
60,208 KB
testcase_04 AC 210 ms
59,200 KB
testcase_05 AC 252 ms
60,256 KB
testcase_06 AC 215 ms
59,788 KB
testcase_07 AC 219 ms
60,920 KB
testcase_08 AC 231 ms
60,332 KB
testcase_09 AC 196 ms
59,036 KB
testcase_10 AC 245 ms
59,920 KB
testcase_11 AC 215 ms
59,668 KB
testcase_12 AC 232 ms
60,292 KB
testcase_13 AC 243 ms
60,240 KB
testcase_14 AC 139 ms
55,744 KB
testcase_15 AC 161 ms
56,708 KB
testcase_16 AC 242 ms
60,076 KB
testcase_17 AC 259 ms
60,200 KB
testcase_18 AC 254 ms
60,556 KB
testcase_19 AC 259 ms
60,088 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 124 ms
56,164 KB
testcase_24 AC 145 ms
56,324 KB
testcase_25 AC 172 ms
54,600 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 214 ms
59,044 KB
testcase_30 AC 195 ms
58,932 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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

}
0