結果

問題 No.5 数字のブロック
ユーザー KibidanKibidan
提出日時 2017-02-21 11:51:17
言語 Java19
(openjdk 21)
結果
AC  
実行時間 215 ms / 5,000 ms
コード長 667 bytes
コンパイル時間 3,647 ms
コンパイル使用メモリ 72,036 KB
実行使用メモリ 60,104 KB
最終ジャッジ日時 2023-08-11 17:07:42
合計ジャッジ時間 8,937 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,700 KB
testcase_01 AC 120 ms
55,708 KB
testcase_02 AC 118 ms
55,980 KB
testcase_03 AC 185 ms
58,684 KB
testcase_04 AC 181 ms
58,808 KB
testcase_05 AC 207 ms
59,376 KB
testcase_06 AC 187 ms
58,480 KB
testcase_07 AC 181 ms
58,816 KB
testcase_08 AC 197 ms
58,596 KB
testcase_09 AC 175 ms
56,832 KB
testcase_10 AC 208 ms
59,912 KB
testcase_11 AC 196 ms
58,192 KB
testcase_12 AC 191 ms
59,208 KB
testcase_13 AC 211 ms
59,244 KB
testcase_14 AC 129 ms
55,776 KB
testcase_15 AC 137 ms
55,764 KB
testcase_16 AC 204 ms
59,348 KB
testcase_17 AC 212 ms
59,088 KB
testcase_18 AC 212 ms
60,104 KB
testcase_19 AC 215 ms
60,100 KB
testcase_20 AC 118 ms
55,400 KB
testcase_21 AC 117 ms
55,696 KB
testcase_22 AC 116 ms
55,640 KB
testcase_23 AC 114 ms
55,704 KB
testcase_24 AC 136 ms
55,936 KB
testcase_25 AC 149 ms
56,128 KB
testcase_26 AC 117 ms
56,128 KB
testcase_27 AC 116 ms
55,548 KB
testcase_28 AC 117 ms
55,604 KB
testcase_29 AC 184 ms
58,972 KB
testcase_30 AC 172 ms
56,384 KB
testcase_31 AC 118 ms
55,884 KB
testcase_32 AC 116 ms
55,828 KB
testcase_33 AC 120 ms
55,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int L=Integer.parseInt(sc.next());
        int N = Integer.parseInt(sc.next());
        int[] block=new int[N];
        for (int i = 0; i < N; i++) {
            block[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(block);

        int count=0;
        for (int i = 0; i < N; i++) {
            L-=block[count];
            
            if (L>=0){
                count++;
            }else{
                break;
            }
        }
        System.out.println(count);

    }
}
0