結果

問題 No.5 数字のブロック
ユーザー face4face4
提出日時 2018-04-09 17:25:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 822 bytes
コンパイル時間 2,634 ms
コンパイル使用メモリ 75,264 KB
実行使用メモリ 40,212 KB
最終ジャッジ日時 2024-04-29 09:44:01
合計ジャッジ時間 5,661 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,868 KB
testcase_01 AC 52 ms
37,052 KB
testcase_02 AC 56 ms
36,976 KB
testcase_03 AC 98 ms
39,084 KB
testcase_04 AC 70 ms
38,420 KB
testcase_05 AC 106 ms
39,628 KB
testcase_06 AC 92 ms
38,680 KB
testcase_07 AC 87 ms
38,492 KB
testcase_08 AC 98 ms
38,812 KB
testcase_09 AC 66 ms
37,376 KB
testcase_10 AC 101 ms
39,336 KB
testcase_11 AC 87 ms
38,480 KB
testcase_12 AC 93 ms
39,140 KB
testcase_13 AC 107 ms
39,840 KB
testcase_14 AC 55 ms
37,096 KB
testcase_15 AC 56 ms
37,028 KB
testcase_16 AC 98 ms
39,024 KB
testcase_17 AC 110 ms
39,604 KB
testcase_18 AC 110 ms
40,000 KB
testcase_19 AC 116 ms
40,212 KB
testcase_20 AC 52 ms
37,020 KB
testcase_21 AC 55 ms
37,016 KB
testcase_22 AC 52 ms
36,652 KB
testcase_23 AC 53 ms
36,984 KB
testcase_24 AC 56 ms
37,020 KB
testcase_25 AC 56 ms
37,036 KB
testcase_26 AC 54 ms
36,744 KB
testcase_27 AC 53 ms
36,696 KB
testcase_28 AC 53 ms
37,196 KB
testcase_29 AC 86 ms
38,332 KB
testcase_30 AC 63 ms
37,276 KB
testcase_31 AC 56 ms
36,968 KB
testcase_32 AC 52 ms
36,780 KB
testcase_33 AC 55 ms
37,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int L = Integer.parseInt(br.readLine());
        int n = Integer.parseInt(br.readLine());

        String[] input = br.readLine().split(" ");
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(input[i]);
        }

        Arrays.sort(arr);

        int sum = 0;
        int i;
        for(i = 0; i < n; i++){
            if(sum + arr[i] <= L){
                sum += arr[i];
            }else{;
                break;
            }
        }

        System.out.println(i);
    }
}
0