結果

問題 No.5 数字のブロック
ユーザー ikawaiikawai
提出日時 2023-09-05 14:39:28
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 623 bytes
コンパイル時間 2,677 ms
コンパイル使用メモリ 80,848 KB
実行使用メモリ 61,172 KB
最終ジャッジ日時 2023-09-05 14:39:40
合計ジャッジ時間 10,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,896 KB
testcase_01 AC 128 ms
56,160 KB
testcase_02 RE -
testcase_03 AC 250 ms
60,268 KB
testcase_04 AC 229 ms
58,656 KB
testcase_05 AC 266 ms
60,184 KB
testcase_06 AC 237 ms
59,456 KB
testcase_07 AC 228 ms
58,804 KB
testcase_08 AC 243 ms
59,916 KB
testcase_09 AC 213 ms
58,748 KB
testcase_10 AC 270 ms
60,244 KB
testcase_11 AC 228 ms
59,920 KB
testcase_12 AC 250 ms
59,664 KB
testcase_13 AC 273 ms
60,320 KB
testcase_14 AC 139 ms
56,196 KB
testcase_15 AC 161 ms
55,984 KB
testcase_16 AC 265 ms
59,960 KB
testcase_17 AC 276 ms
61,172 KB
testcase_18 AC 288 ms
60,624 KB
testcase_19 AC 289 ms
61,036 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 128 ms
55,872 KB
testcase_24 AC 154 ms
56,120 KB
testcase_25 AC 193 ms
55,940 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 234 ms
59,608 KB
testcase_30 AC 209 ms
58,672 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();
    	int cnt = 0;
    	
    	for (int i = 0; i < n; i++) {
    		list.add(sc.nextInt());
    	}
    	
    	Collections.sort(list);
    	
    	for (int i = 0; l >= 0; i++) {
    		l -= list.get(i);
    		if (l >= 0) {
    			
    			cnt++;
    		} 
    	}
    	
    	System.out.println(cnt);
    }
}
0