結果

問題 No.5 数字のブロック
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-13 19:30:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 374 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 71,224 KB
実行使用メモリ 60,888 KB
最終ジャッジ日時 2023-10-11 12:24:12
合計ジャッジ時間 10,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,856 KB
testcase_01 AC 122 ms
55,924 KB
testcase_02 WA -
testcase_03 AC 228 ms
59,492 KB
testcase_04 AC 215 ms
59,108 KB
testcase_05 AC 240 ms
60,248 KB
testcase_06 AC 219 ms
59,852 KB
testcase_07 AC 214 ms
59,320 KB
testcase_08 AC 221 ms
59,700 KB
testcase_09 AC 195 ms
58,488 KB
testcase_10 AC 252 ms
60,392 KB
testcase_11 AC 214 ms
59,400 KB
testcase_12 AC 241 ms
60,636 KB
testcase_13 AC 243 ms
60,076 KB
testcase_14 AC 138 ms
55,568 KB
testcase_15 AC 151 ms
56,500 KB
testcase_16 AC 254 ms
60,748 KB
testcase_17 AC 260 ms
60,612 KB
testcase_18 AC 267 ms
60,888 KB
testcase_19 AC 260 ms
60,536 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 123 ms
55,848 KB
testcase_24 AC 151 ms
55,588 KB
testcase_25 AC 175 ms
55,536 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 205 ms
58,832 KB
testcase_30 AC 199 ms
58,712 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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