結果

問題 No.5 数字のブロック
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 18:09:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 3,131 ms
コンパイル使用メモリ 75,068 KB
実行使用メモリ 58,864 KB
最終ジャッジ日時 2024-04-27 15:38:11
合計ジャッジ時間 9,877 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
52,516 KB
testcase_01 AC 120 ms
54,188 KB
testcase_02 AC 119 ms
53,852 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 134 ms
54,220 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 118 ms
53,788 KB
testcase_21 WA -
testcase_22 AC 112 ms
54,184 KB
testcase_23 AC 101 ms
52,592 KB
testcase_24 WA -
testcase_25 AC 168 ms
54,520 KB
testcase_26 AC 117 ms
53,904 KB
testcase_27 AC 105 ms
52,984 KB
testcase_28 AC 116 ms
54,028 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 113 ms
54,144 KB
testcase_32 AC 105 ms
52,620 KB
testcase_33 AC 106 ms
52,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		Set<Integer> set = new TreeSet<Integer>();
		int len = sc.nextInt(), n = sc.nextInt();
		for(int i = 0; i < n; i++){
			set.add(sc.nextInt());
		}
		int cnt = 0, sum = 0;
		for(int i : set){
			sum += i;
			if(sum <= len){
				cnt++;
			} else {
				break;
			}
		}
		System.out.println(cnt);
	}
}
0