結果

問題 No.5 数字のブロック
ユーザー skylineskyline
提出日時 2020-02-01 13:48:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 264 ms / 5,000 ms
コード長 986 bytes
コンパイル時間 2,603 ms
コンパイル使用メモリ 76,916 KB
実行使用メモリ 61,968 KB
最終ジャッジ日時 2023-10-18 23:58:06
合計ジャッジ時間 10,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,224 KB
testcase_01 AC 140 ms
57,488 KB
testcase_02 AC 141 ms
57,728 KB
testcase_03 AC 245 ms
61,016 KB
testcase_04 AC 223 ms
60,556 KB
testcase_05 AC 253 ms
61,436 KB
testcase_06 AC 245 ms
60,684 KB
testcase_07 AC 227 ms
60,100 KB
testcase_08 AC 238 ms
60,728 KB
testcase_09 AC 203 ms
58,220 KB
testcase_10 AC 262 ms
61,452 KB
testcase_11 AC 222 ms
60,800 KB
testcase_12 AC 239 ms
60,736 KB
testcase_13 AC 251 ms
61,520 KB
testcase_14 AC 148 ms
57,256 KB
testcase_15 AC 153 ms
57,444 KB
testcase_16 AC 250 ms
61,336 KB
testcase_17 AC 262 ms
61,648 KB
testcase_18 AC 264 ms
61,968 KB
testcase_19 AC 263 ms
61,968 KB
testcase_20 AC 139 ms
57,684 KB
testcase_21 AC 138 ms
57,416 KB
testcase_22 AC 136 ms
57,276 KB
testcase_23 AC 138 ms
57,704 KB
testcase_24 AC 158 ms
57,664 KB
testcase_25 AC 187 ms
58,036 KB
testcase_26 AC 147 ms
57,160 KB
testcase_27 AC 140 ms
57,204 KB
testcase_28 AC 137 ms
57,268 KB
testcase_29 AC 226 ms
60,260 KB
testcase_30 AC 207 ms
58,056 KB
testcase_31 AC 139 ms
57,760 KB
testcase_32 AC 137 ms
57,204 KB
testcase_33 AC 136 ms
57,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Main {
    
    public static void main(String[] args) {
        
        No0005 no = new No0005();

        System.out.println(no.result());
        
    }
    
}

class No0005 {
    private int l;
    private int n;
    private List<Integer> w;
    private int result;
    
    public No0005() {
        Scanner sc = new Scanner(System.in);
        this.l = sc.nextInt();
        this.n = sc.nextInt();
        this.w = new ArrayList<>(this.n);
        for (int i = 0; i < this.n; i++) {
            this.w.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(this.w);
        int totalW = 0;
        for (Integer i : this.w) {
            totalW += i;
            if (totalW > this.l) {
                break;
            }
            this.result++;
        }
    }
    
    public String result() {
        return String.valueOf(this.result);
    }
}
0