結果

問題 No.5 数字のブロック
ユーザー ikawaiikawai
提出日時 2023-09-05 14:56:40
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 638 bytes
コンパイル時間 3,227 ms
コンパイル使用メモリ 73,936 KB
実行使用メモリ 62,380 KB
最終ジャッジ日時 2023-09-05 14:56:51
合計ジャッジ時間 11,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
39,760 KB
testcase_01 AC 123 ms
39,148 KB
testcase_02 AC 123 ms
39,144 KB
testcase_03 AC 276 ms
56,408 KB
testcase_04 AC 231 ms
44,072 KB
testcase_05 AC 275 ms
60,408 KB
testcase_06 AC 245 ms
62,380 KB
testcase_07 AC 235 ms
59,424 KB
testcase_08 AC 242 ms
59,464 KB
testcase_09 AC 209 ms
58,624 KB
testcase_10 AC 276 ms
60,808 KB
testcase_11 AC 221 ms
59,776 KB
testcase_12 AC 253 ms
60,056 KB
testcase_13 AC 266 ms
60,432 KB
testcase_14 AC 144 ms
55,840 KB
testcase_15 AC 156 ms
55,872 KB
testcase_16 AC 269 ms
59,844 KB
testcase_17 AC 281 ms
60,776 KB
testcase_18 AC 278 ms
60,456 KB
testcase_19 AC 294 ms
60,976 KB
testcase_20 RE -
testcase_21 AC 126 ms
56,132 KB
testcase_22 AC 126 ms
55,648 KB
testcase_23 AC 127 ms
55,552 KB
testcase_24 AC 157 ms
55,916 KB
testcase_25 AC 191 ms
55,920 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 221 ms
59,284 KB
testcase_30 AC 209 ms
58,388 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
class Wandbox
{
    public static void main(String[] args)
    {
    	Scanner sc = new Scanner(System.in);
    	
    	List<Integer> list = new ArrayList<>();
    	
    	int l = sc.nextInt();
    	int n = sc.nextInt();
    	
    	for (int i = 0; i < n; i++) {
    		list.add(sc.nextInt());
    	}
    	
    	Collections.sort(list);
    	
    	int sum = 0;
    	int cnt = 0;
    	for (int i = 0; sum < l; i++) {
    		sum += list.get(i);
    		if (sum <= l) {
    			cnt++;
    		} 
    	}
    	
    	System.out.println(cnt);
    }
}
0