結果

問題 No.5 数字のブロック
ユーザー kuramubonnkuramubonn
提出日時 2023-02-01 21:29:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 289 ms / 5,000 ms
コード長 559 bytes
コンパイル時間 3,219 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 60,844 KB
最終ジャッジ日時 2023-09-14 07:17:47
合計ジャッジ時間 10,771 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,920 KB
testcase_01 AC 125 ms
55,772 KB
testcase_02 AC 124 ms
55,944 KB
testcase_03 AC 255 ms
60,300 KB
testcase_04 AC 235 ms
60,844 KB
testcase_05 AC 269 ms
60,252 KB
testcase_06 AC 238 ms
59,080 KB
testcase_07 AC 227 ms
59,456 KB
testcase_08 AC 241 ms
59,548 KB
testcase_09 AC 207 ms
58,792 KB
testcase_10 AC 271 ms
60,484 KB
testcase_11 AC 229 ms
59,404 KB
testcase_12 AC 245 ms
59,544 KB
testcase_13 AC 261 ms
60,036 KB
testcase_14 AC 138 ms
55,980 KB
testcase_15 AC 150 ms
55,936 KB
testcase_16 AC 264 ms
59,928 KB
testcase_17 AC 289 ms
60,700 KB
testcase_18 AC 275 ms
60,504 KB
testcase_19 AC 286 ms
59,896 KB
testcase_20 AC 126 ms
55,624 KB
testcase_21 AC 124 ms
55,760 KB
testcase_22 AC 124 ms
55,796 KB
testcase_23 AC 125 ms
56,396 KB
testcase_24 AC 155 ms
56,232 KB
testcase_25 AC 186 ms
55,988 KB
testcase_26 AC 125 ms
55,832 KB
testcase_27 AC 125 ms
55,700 KB
testcase_28 AC 125 ms
55,948 KB
testcase_29 AC 228 ms
59,716 KB
testcase_30 AC 206 ms
58,468 KB
testcase_31 AC 125 ms
56,240 KB
testcase_32 AC 126 ms
55,952 KB
testcase_33 AC 125 ms
55,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int haba = sc.nextInt(),num = sc.nextInt();
		ArrayList <Integer> list = new ArrayList<Integer>();
		
		for(int i = 0 ; i < num ; i++)list.add(sc.nextInt());
		Collections.sort(list);
		int count = 0 , kosu = 0;
		
		for(int i = 0; i < num ; i++) {
			count += list.get(i);
			if(count > haba)break;
			kosu++;
			if(count == haba)break;
		}
		
		System.out.println(kosu);
		
	}
}
0