結果

問題 No.5 数字のブロック
ユーザー masuyuumasuyuu
提出日時 2020-09-17 21:13:10
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 4,945 ms
コンパイル使用メモリ 82,776 KB
実行使用メモリ 61,052 KB
最終ジャッジ日時 2023-09-04 07:35:11
合計ジャッジ時間 13,518 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,828 KB
testcase_01 AC 125 ms
55,996 KB
testcase_02 WA -
testcase_03 AC 247 ms
60,108 KB
testcase_04 AC 229 ms
59,464 KB
testcase_05 WA -
testcase_06 AC 238 ms
60,084 KB
testcase_07 AC 215 ms
59,148 KB
testcase_08 AC 240 ms
59,532 KB
testcase_09 AC 206 ms
58,584 KB
testcase_10 AC 268 ms
60,232 KB
testcase_11 AC 228 ms
59,484 KB
testcase_12 AC 245 ms
59,616 KB
testcase_13 AC 255 ms
60,052 KB
testcase_14 AC 148 ms
55,472 KB
testcase_15 WA -
testcase_16 AC 263 ms
60,168 KB
testcase_17 AC 284 ms
60,648 KB
testcase_18 AC 287 ms
61,052 KB
testcase_19 AC 295 ms
60,476 KB
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 125 ms
55,808 KB
testcase_24 AC 156 ms
56,256 KB
testcase_25 AC 191 ms
55,964 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 WA -
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