結果

問題 No.5 数字のブロック
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 21:04:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 74,908 KB
実行使用メモリ 47,652 KB
最終ジャッジ日時 2024-05-04 00:26:21
合計ジャッジ時間 8,657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
41,400 KB
testcase_01 AC 124 ms
41,388 KB
testcase_02 WA -
testcase_03 AC 223 ms
46,568 KB
testcase_04 AC 204 ms
45,636 KB
testcase_05 WA -
testcase_06 AC 221 ms
46,112 KB
testcase_07 AC 196 ms
45,676 KB
testcase_08 AC 215 ms
46,936 KB
testcase_09 AC 196 ms
43,784 KB
testcase_10 AC 243 ms
46,580 KB
testcase_11 AC 202 ms
46,504 KB
testcase_12 AC 223 ms
46,456 KB
testcase_13 AC 227 ms
47,368 KB
testcase_14 AC 127 ms
41,544 KB
testcase_15 WA -
testcase_16 AC 232 ms
46,280 KB
testcase_17 AC 238 ms
47,316 KB
testcase_18 AC 235 ms
47,400 KB
testcase_19 AC 242 ms
47,652 KB
testcase_20 AC 112 ms
41,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 110 ms
41,396 KB
testcase_24 AC 143 ms
42,140 KB
testcase_25 AC 161 ms
42,140 KB
testcase_26 AC 112 ms
41,660 KB
testcase_27 AC 119 ms
41,180 KB
testcase_28 AC 114 ms
41,492 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 115 ms
41,592 KB
testcase_32 AC 119 ms
41,380 KB
testcase_33 AC 104 ms
41,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        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 i =0;
        int s =0;
        int c =0;
        while(true){
                s=s+W[i];
                if(s>=L){break;}
                i++;
                c++;
               if(c==N){break;}
        }
        System.out.println(c);
    }
}
0