結果

問題 No.5 数字のブロック
ユーザー KatoooooKatooooo
提出日時 2017-09-11 22:43:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 5,000 ms
コード長 642 bytes
コンパイル時間 3,524 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 60,440 KB
最終ジャッジ日時 2023-08-11 17:46:24
合計ジャッジ時間 11,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,856 KB
testcase_01 AC 128 ms
56,004 KB
testcase_02 AC 127 ms
53,516 KB
testcase_03 AC 236 ms
59,388 KB
testcase_04 AC 220 ms
59,968 KB
testcase_05 AC 251 ms
60,096 KB
testcase_06 AC 217 ms
59,296 KB
testcase_07 AC 222 ms
58,692 KB
testcase_08 AC 237 ms
59,036 KB
testcase_09 AC 202 ms
58,696 KB
testcase_10 AC 248 ms
60,328 KB
testcase_11 AC 221 ms
59,300 KB
testcase_12 AC 241 ms
59,856 KB
testcase_13 AC 249 ms
60,180 KB
testcase_14 AC 142 ms
55,508 KB
testcase_15 AC 156 ms
55,796 KB
testcase_16 AC 258 ms
60,136 KB
testcase_17 AC 256 ms
58,528 KB
testcase_18 AC 254 ms
60,324 KB
testcase_19 AC 268 ms
60,440 KB
testcase_20 AC 127 ms
55,752 KB
testcase_21 AC 127 ms
55,704 KB
testcase_22 AC 130 ms
55,704 KB
testcase_23 AC 127 ms
55,944 KB
testcase_24 AC 153 ms
58,076 KB
testcase_25 AC 189 ms
56,208 KB
testcase_26 AC 127 ms
55,620 KB
testcase_27 AC 128 ms
56,040 KB
testcase_28 AC 126 ms
55,764 KB
testcase_29 AC 210 ms
58,932 KB
testcase_30 AC 207 ms
58,544 KB
testcase_31 AC 127 ms
55,980 KB
testcase_32 AC 127 ms
55,764 KB
testcase_33 AC 127 ms
55,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args){
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int N = sc.nextInt();
        int []W = new int[N];
        
        for(int i = 0; i<N; i++){
            W[i] = sc.nextInt();
        }
        
        Arrays.sort(W);
        
        int In = 0;
        for(int i = 0; i<N; i++){
            L -= W[i];
            if(L>=0){
                In++;
            }else{
                break;
            }
        }
        System.out.println(In);
        
    }
}
0