結果

問題 No.5 数字のブロック
ユーザー KatoooooKatooooo
提出日時 2017-09-11 22:41:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 74,368 KB
実行使用メモリ 47,728 KB
最終ジャッジ日時 2024-04-25 06:56:28
合計ジャッジ時間 8,529 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
40,320 KB
testcase_01 AC 115 ms
41,112 KB
testcase_02 WA -
testcase_03 AC 215 ms
46,456 KB
testcase_04 AC 194 ms
45,504 KB
testcase_05 WA -
testcase_06 AC 211 ms
46,120 KB
testcase_07 AC 218 ms
45,592 KB
testcase_08 AC 230 ms
46,564 KB
testcase_09 AC 179 ms
43,500 KB
testcase_10 AC 230 ms
47,048 KB
testcase_11 AC 195 ms
46,328 KB
testcase_12 AC 231 ms
46,364 KB
testcase_13 AC 235 ms
47,092 KB
testcase_14 AC 124 ms
41,728 KB
testcase_15 WA -
testcase_16 AC 228 ms
47,028 KB
testcase_17 AC 231 ms
47,600 KB
testcase_18 AC 245 ms
46,556 KB
testcase_19 AC 241 ms
47,728 KB
testcase_20 AC 104 ms
39,960 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 113 ms
40,980 KB
testcase_24 AC 144 ms
41,868 KB
testcase_25 AC 158 ms
41,988 KB
testcase_26 AC 110 ms
40,176 KB
testcase_27 AC 103 ms
39,908 KB
testcase_28 AC 109 ms
40,096 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 110 ms
40,208 KB
testcase_32 AC 109 ms
41,224 KB
testcase_33 AC 101 ms
40,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args){
        // Here your code !
        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 In = 0;
        for(int i = 0; i<N; i++){
            L -= W[i];
            if(L>0){
                In++;
            }else{
                break;
            }
        }
        System.out.println(In);
        
    }
}
0