結果

問題 No.5 数字のブロック
ユーザー springspring
提出日時 2019-06-12 15:37:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 295 ms / 5,000 ms
コード長 651 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 59,152 KB
最終ジャッジ日時 2024-04-19 04:23:31
合計ジャッジ時間 10,528 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
54,360 KB
testcase_01 AC 138 ms
53,916 KB
testcase_02 AC 135 ms
54,160 KB
testcase_03 AC 266 ms
58,256 KB
testcase_04 AC 241 ms
57,724 KB
testcase_05 AC 275 ms
58,720 KB
testcase_06 AC 250 ms
57,940 KB
testcase_07 AC 240 ms
57,784 KB
testcase_08 AC 259 ms
58,376 KB
testcase_09 AC 220 ms
56,992 KB
testcase_10 AC 286 ms
58,916 KB
testcase_11 AC 240 ms
57,716 KB
testcase_12 AC 259 ms
58,524 KB
testcase_13 AC 270 ms
58,616 KB
testcase_14 AC 156 ms
54,568 KB
testcase_15 AC 174 ms
54,284 KB
testcase_16 AC 274 ms
58,424 KB
testcase_17 AC 293 ms
59,052 KB
testcase_18 AC 291 ms
58,924 KB
testcase_19 AC 295 ms
59,152 KB
testcase_20 AC 136 ms
54,216 KB
testcase_21 AC 135 ms
54,188 KB
testcase_22 AC 135 ms
54,476 KB
testcase_23 AC 136 ms
53,988 KB
testcase_24 AC 175 ms
54,340 KB
testcase_25 AC 185 ms
54,232 KB
testcase_26 AC 135 ms
54,196 KB
testcase_27 AC 135 ms
54,148 KB
testcase_28 AC 136 ms
53,820 KB
testcase_29 AC 240 ms
57,508 KB
testcase_30 AC 218 ms
56,668 KB
testcase_31 AC 134 ms
54,012 KB
testcase_32 AC 134 ms
54,084 KB
testcase_33 AC 137 ms
54,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int box = sc.nextInt();
		int count = sc.nextInt();
		ArrayList<Integer> boxlist = new ArrayList<Integer>();
		for(int i=0;i<count;i++){
			int input = sc.nextInt();
			boxlist.add(input);
		}
		sc.close();
		Collections.sort(boxlist);
		int total=0;
		int result = 0;
		for(int k=0;box>total&&boxlist.size()>k;k++){
			total += boxlist.get(k);
			if(box>=total){
				result++;
			}else{
				break;
			}
		}
		System.out.println(result);
	}// mainmethod

} // cla
0