結果

問題 No.5 数字のブロック
ユーザー shinshin
提出日時 2022-05-12 18:18:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 3,452 ms
コンパイル使用メモリ 73,076 KB
実行使用メモリ 62,180 KB
最終ジャッジ日時 2023-09-27 17:53:25
合計ジャッジ時間 10,729 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,664 KB
testcase_01 AC 123 ms
55,756 KB
testcase_02 AC 122 ms
55,804 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 132 ms
55,684 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 125 ms
55,872 KB
testcase_21 WA -
testcase_22 AC 124 ms
56,048 KB
testcase_23 AC 122 ms
55,664 KB
testcase_24 WA -
testcase_25 AC 159 ms
54,080 KB
testcase_26 AC 124 ms
55,852 KB
testcase_27 AC 123 ms
56,076 KB
testcase_28 AC 123 ms
56,128 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 123 ms
55,720 KB
testcase_32 AC 121 ms
56,228 KB
testcase_33 AC 121 ms
56,020 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;
		
		for(int w : ts) {
			L = L - w;
			if(L < 0) {
				break;
			}else {
				i++;
			}
		}

		System.out.println(i);
	}

}
0