結果

問題 No.5 数字のブロック
ユーザー mits58mits58
提出日時 2015-07-18 01:06:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 1,860 ms
コンパイル使用メモリ 71,848 KB
実行使用メモリ 61,068 KB
最終ジャッジ日時 2023-09-22 18:48:03
合計ジャッジ時間 9,260 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,412 KB
testcase_01 AC 121 ms
56,212 KB
testcase_02 WA -
testcase_03 AC 229 ms
59,836 KB
testcase_04 AC 207 ms
59,000 KB
testcase_05 AC 246 ms
59,888 KB
testcase_06 AC 216 ms
59,648 KB
testcase_07 AC 211 ms
59,736 KB
testcase_08 AC 231 ms
59,392 KB
testcase_09 AC 191 ms
58,488 KB
testcase_10 AC 238 ms
60,020 KB
testcase_11 AC 220 ms
60,092 KB
testcase_12 AC 231 ms
59,868 KB
testcase_13 AC 239 ms
60,320 KB
testcase_14 AC 133 ms
56,292 KB
testcase_15 AC 144 ms
55,592 KB
testcase_16 AC 247 ms
60,148 KB
testcase_17 AC 250 ms
60,620 KB
testcase_18 AC 249 ms
60,672 KB
testcase_19 AC 257 ms
61,068 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 124 ms
55,844 KB
testcase_24 AC 147 ms
56,600 KB
testcase_25 AC 177 ms
56,344 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 200 ms
59,136 KB
testcase_30 AC 193 ms
58,748 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
        	int l=sc.nextInt();
        	int n=sc.nextInt();
        	int result=0;
        	int[] box=new int[n];
        	
        	for(int i=0;i<n;i++){
        		box[i]=sc.nextInt();
        	}
        	
        	Arrays.sort(box);
        	
        	for(int i=0;i<n;i++){
        		result+=box[i];
        		if(result<=l) continue;
        		else{
        			System.out.println(i);
        			break;
        		}
        	}
        	
        }
    }
}
0