結果

問題 No.5 数字のブロック
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 00:46:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 427 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 75,220 KB
実行使用メモリ 59,232 KB
最終ジャッジ日時 2024-04-09 20:41:24
合計ジャッジ時間 8,968 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
54,304 KB
testcase_01 AC 105 ms
52,840 KB
testcase_02 WA -
testcase_03 AC 225 ms
58,384 KB
testcase_04 AC 203 ms
57,132 KB
testcase_05 WA -
testcase_06 AC 215 ms
57,764 KB
testcase_07 AC 204 ms
57,596 KB
testcase_08 AC 217 ms
58,292 KB
testcase_09 AC 181 ms
56,912 KB
testcase_10 AC 295 ms
58,356 KB
testcase_11 AC 194 ms
57,572 KB
testcase_12 AC 225 ms
58,700 KB
testcase_13 AC 234 ms
59,232 KB
testcase_14 AC 131 ms
54,448 KB
testcase_15 WA -
testcase_16 AC 231 ms
58,608 KB
testcase_17 AC 246 ms
58,884 KB
testcase_18 AC 242 ms
58,484 KB
testcase_19 AC 243 ms
59,192 KB
testcase_20 AC 110 ms
53,164 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 120 ms
53,944 KB
testcase_24 AC 137 ms
54,288 KB
testcase_25 AC 158 ms
54,248 KB
testcase_26 AC 117 ms
54,120 KB
testcase_27 AC 120 ms
54,008 KB
testcase_28 AC 121 ms
54,172 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 104 ms
53,000 KB
testcase_32 AC 119 ms
53,932 KB
testcase_33 AC 107 ms
53,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int L = sc.nextInt();
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
		}
		Arrays.sort(ints);
		int count = 0;
		for (int i=0; i<n; i++) {
			if (L-ints[i] > 0) {count++; L-=ints[i];}
			else {break;}
		}
		System.out.println(count);
	}
}
0