結果

問題 No.5 数字のブロック
ユーザー kashiwagi513kashiwagi513
提出日時 2019-02-19 20:22:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 77,416 KB
実行使用メモリ 58,032 KB
最終ジャッジ日時 2024-04-20 20:24:22
合計ジャッジ時間 9,628 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,096 KB
testcase_01 AC 127 ms
41,696 KB
testcase_02 WA -
testcase_03 AC 223 ms
45,572 KB
testcase_04 AC 195 ms
44,064 KB
testcase_05 WA -
testcase_06 AC 215 ms
44,260 KB
testcase_07 AC 198 ms
43,980 KB
testcase_08 AC 210 ms
45,240 KB
testcase_09 AC 188 ms
42,988 KB
testcase_10 AC 235 ms
46,880 KB
testcase_11 AC 209 ms
44,112 KB
testcase_12 AC 220 ms
44,908 KB
testcase_13 AC 232 ms
46,252 KB
testcase_14 AC 136 ms
41,356 KB
testcase_15 WA -
testcase_16 AC 224 ms
46,420 KB
testcase_17 AC 238 ms
46,976 KB
testcase_18 AC 240 ms
46,976 KB
testcase_19 AC 242 ms
47,424 KB
testcase_20 AC 126 ms
41,416 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 129 ms
41,612 KB
testcase_24 AC 145 ms
41,696 KB
testcase_25 AC 165 ms
42,028 KB
testcase_26 AC 125 ms
41,888 KB
testcase_27 AC 124 ms
41,332 KB
testcase_28 AC 125 ms
41,604 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 126 ms
41,460 KB
testcase_32 AC 126 ms
41,416 KB
testcase_33 AC 128 ms
41,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

class Main{
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int wid = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        List<Integer> box = new ArrayList<Integer>();
        for(int i = 0; i < num; i++){
            box.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(box);
        int temp = 0;
        int ct = 0;
        for(Iterator it = box.iterator(); it.hasNext();){
            temp += ((Integer)it.next()).intValue();
            if(temp < wid) { ct++;  } else {break;}
        }
        System.out.println(ct);
    }
}
0