結果

問題 No.5 数字のブロック
ユーザー prestopresto
提出日時 2015-10-08 22:52:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 522 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 72,720 KB
実行使用メモリ 60,420 KB
最終ジャッジ日時 2023-09-27 08:09:36
合計ジャッジ時間 9,600 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,632 KB
testcase_01 AC 120 ms
55,824 KB
testcase_02 WA -
testcase_03 AC 227 ms
59,676 KB
testcase_04 AC 206 ms
59,372 KB
testcase_05 AC 237 ms
60,080 KB
testcase_06 AC 214 ms
59,532 KB
testcase_07 AC 207 ms
59,304 KB
testcase_08 AC 225 ms
60,328 KB
testcase_09 AC 191 ms
58,996 KB
testcase_10 AC 238 ms
60,252 KB
testcase_11 AC 212 ms
59,436 KB
testcase_12 AC 227 ms
59,704 KB
testcase_13 AC 241 ms
60,372 KB
testcase_14 AC 132 ms
55,660 KB
testcase_15 AC 152 ms
56,452 KB
testcase_16 AC 235 ms
59,840 KB
testcase_17 AC 259 ms
59,876 KB
testcase_18 AC 244 ms
60,316 KB
testcase_19 AC 254 ms
60,420 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 117 ms
56,164 KB
testcase_24 AC 143 ms
56,072 KB
testcase_25 AC 170 ms
56,196 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 207 ms
58,960 KB
testcase_30 AC 193 ms
58,844 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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];
        int sum = 0;
        for(int i = 0; i < n; i++) w[i] = sc.nextInt();
        Arrays.sort(w);
        for(int i = 0; i < n; i++){
           sum += w[i];
           if(sum > l){
             System.out.println(i);
             return;
           }
        }
    }
}
0