結果

問題 No.5 数字のブロック
ユーザー masuyuumasuyuu
提出日時 2020-09-17 21:15:08
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 532 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 72,980 KB
実行使用メモリ 60,672 KB
最終ジャッジ日時 2023-09-04 07:35:30
合計ジャッジ時間 10,192 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,472 KB
testcase_01 AC 128 ms
56,308 KB
testcase_02 AC 129 ms
55,548 KB
testcase_03 AC 254 ms
59,628 KB
testcase_04 AC 234 ms
59,660 KB
testcase_05 AC 262 ms
60,108 KB
testcase_06 AC 240 ms
59,484 KB
testcase_07 AC 221 ms
59,716 KB
testcase_08 AC 245 ms
59,904 KB
testcase_09 AC 207 ms
58,676 KB
testcase_10 AC 273 ms
60,416 KB
testcase_11 AC 230 ms
60,004 KB
testcase_12 AC 251 ms
60,240 KB
testcase_13 AC 271 ms
59,876 KB
testcase_14 AC 139 ms
55,660 KB
testcase_15 AC 157 ms
55,508 KB
testcase_16 AC 261 ms
60,112 KB
testcase_17 AC 291 ms
60,656 KB
testcase_18 AC 287 ms
60,672 KB
testcase_19 AC 302 ms
60,636 KB
testcase_20 RE -
testcase_21 AC 128 ms
55,768 KB
testcase_22 AC 129 ms
53,488 KB
testcase_23 AC 127 ms
56,028 KB
testcase_24 AC 157 ms
56,236 KB
testcase_25 AC 187 ms
56,096 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 230 ms
59,160 KB
testcase_30 AC 204 ms
58,656 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c = sc.nextInt();
		int h = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i=0;i<h;i++) {
			int x = sc.nextInt();
			a.add(x);
		}
		Collections.sort(a);
		int sum =0;
		int cnt=0;
		int g=0;
		while(sum<c) {
			sum+=a.get(g);
			if(sum<=c) {
				cnt++;
			}
			g++;
		}
		System.out.println(cnt);
	}
}
0