結果

問題 No.5 数字のブロック
ユーザー kaoetayakaoetaya
提出日時 2016-12-09 17:15:31
言語 Java19
(openjdk 21)
結果
AC  
実行時間 255 ms / 5,000 ms
コード長 539 bytes
コンパイル時間 3,641 ms
コンパイル使用メモリ 72,376 KB
実行使用メモリ 60,904 KB
最終ジャッジ日時 2023-08-11 16:56:52
合計ジャッジ時間 11,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,840 KB
testcase_01 AC 124 ms
56,124 KB
testcase_02 AC 122 ms
55,996 KB
testcase_03 AC 226 ms
59,420 KB
testcase_04 AC 207 ms
59,052 KB
testcase_05 AC 240 ms
59,956 KB
testcase_06 AC 224 ms
59,260 KB
testcase_07 AC 212 ms
59,404 KB
testcase_08 AC 228 ms
58,904 KB
testcase_09 AC 194 ms
58,424 KB
testcase_10 AC 244 ms
60,176 KB
testcase_11 AC 217 ms
59,580 KB
testcase_12 AC 234 ms
59,796 KB
testcase_13 AC 246 ms
60,104 KB
testcase_14 AC 138 ms
56,008 KB
testcase_15 AC 153 ms
56,252 KB
testcase_16 AC 240 ms
60,452 KB
testcase_17 AC 248 ms
60,716 KB
testcase_18 AC 255 ms
60,172 KB
testcase_19 AC 255 ms
60,904 KB
testcase_20 AC 121 ms
56,028 KB
testcase_21 AC 123 ms
56,312 KB
testcase_22 AC 125 ms
56,236 KB
testcase_23 AC 127 ms
55,880 KB
testcase_24 AC 151 ms
55,920 KB
testcase_25 AC 184 ms
57,064 KB
testcase_26 AC 125 ms
55,536 KB
testcase_27 AC 126 ms
56,440 KB
testcase_28 AC 125 ms
55,768 KB
testcase_29 AC 207 ms
59,248 KB
testcase_30 AC 191 ms
58,748 KB
testcase_31 AC 125 ms
56,092 KB
testcase_32 AC 125 ms
55,836 KB
testcase_33 AC 127 ms
53,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Test {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int l = s.nextInt();
        int n = s.nextInt();
        int w[] = new int[n];

        for(int i=0;i<n;i++){
        	w[i] = s.nextInt();
        }

        Arrays.sort(w);

        int count = 0,i = 0;

        for(i=0;i<n;i++){
        	l -= w[i];
        	if(l >= 0){
        		count++;
        	}
        	else{
        		break;
        	}
        }

        System.out.println(count);

    }
}
0