結果

問題 No.5 数字のブロック
ユーザー springspring
提出日時 2019-06-12 15:33:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 2,377 ms
コンパイル使用メモリ 76,904 KB
実行使用メモリ 59,072 KB
最終ジャッジ日時 2024-04-19 04:13:55
合計ジャッジ時間 10,443 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
41,656 KB
testcase_01 AC 144 ms
41,324 KB
testcase_02 WA -
testcase_03 AC 278 ms
46,224 KB
testcase_04 AC 244 ms
46,156 KB
testcase_05 WA -
testcase_06 AC 261 ms
46,028 KB
testcase_07 AC 235 ms
46,500 KB
testcase_08 AC 257 ms
46,492 KB
testcase_09 AC 221 ms
43,344 KB
testcase_10 AC 296 ms
47,896 KB
testcase_11 AC 248 ms
46,372 KB
testcase_12 AC 265 ms
46,212 KB
testcase_13 AC 278 ms
46,644 KB
testcase_14 AC 159 ms
42,128 KB
testcase_15 WA -
testcase_16 AC 277 ms
47,888 KB
testcase_17 AC 282 ms
48,136 KB
testcase_18 AC 271 ms
48,232 KB
testcase_19 AC 293 ms
48,224 KB
testcase_20 AC 132 ms
41,912 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 131 ms
41,672 KB
testcase_24 AC 166 ms
41,872 KB
testcase_25 AC 176 ms
42,496 KB
testcase_26 AC 131 ms
41,648 KB
testcase_27 AC 115 ms
41,556 KB
testcase_28 AC 129 ms
41,936 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 122 ms
41,776 KB
testcase_32 AC 124 ms
41,464 KB
testcase_33 AC 124 ms
41,600 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

} // class
0