結果

問題 No.5 数字のブロック
ユーザー shinshin
提出日時 2022-05-12 15:35:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 517 bytes
コンパイル時間 3,458 ms
コンパイル使用メモリ 72,916 KB
実行使用メモリ 63,644 KB
最終ジャッジ日時 2023-09-27 15:05:36
合計ジャッジ時間 11,369 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
56,000 KB
testcase_01 AC 109 ms
55,924 KB
testcase_02 AC 110 ms
55,696 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 119 ms
55,716 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 106 ms
56,112 KB
testcase_21 RE -
testcase_22 AC 109 ms
55,476 KB
testcase_23 AC 110 ms
56,536 KB
testcase_24 WA -
testcase_25 AC 155 ms
57,060 KB
testcase_26 AC 110 ms
55,912 KB
testcase_27 AC 110 ms
55,808 KB
testcase_28 AC 106 ms
56,272 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 110 ms
56,160 KB
testcase_32 AC 109 ms
56,112 KB
testcase_33 AC 107 ms
56,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.TreeSet;
public class No5 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		TreeSet<Integer> ts = new TreeSet();
		int L = Integer.parseInt(s.nextLine()),N = Integer.parseInt(s.nextLine()),i = 0,count = 0;
		for(i = 0;i < N;i++) {
			ts.add(Integer.parseInt(s.next()));
		}
		s.close();
		
		i = 0;
		
		while(count <= L && i < N){
			count += ts.pollFirst();
			if(count > L) {
				break;
			}
			i++;
		}

		System.out.println(i);
	}

}
0