結果

問題 No.5 数字のブロック
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-11 21:12:37
言語 Java19
(openjdk 21)
結果
AC  
実行時間 263 ms / 5,000 ms
コード長 468 bytes
コンパイル時間 2,224 ms
コンパイル使用メモリ 72,400 KB
実行使用メモリ 60,620 KB
最終ジャッジ日時 2023-08-11 17:29:53
合計ジャッジ時間 10,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,636 KB
testcase_01 AC 129 ms
55,596 KB
testcase_02 AC 128 ms
55,776 KB
testcase_03 AC 246 ms
59,792 KB
testcase_04 AC 222 ms
59,948 KB
testcase_05 AC 250 ms
59,936 KB
testcase_06 AC 234 ms
58,876 KB
testcase_07 AC 227 ms
59,368 KB
testcase_08 AC 241 ms
59,628 KB
testcase_09 AC 200 ms
57,964 KB
testcase_10 AC 263 ms
60,424 KB
testcase_11 AC 226 ms
57,260 KB
testcase_12 AC 242 ms
59,592 KB
testcase_13 AC 252 ms
60,364 KB
testcase_14 AC 143 ms
55,588 KB
testcase_15 AC 159 ms
56,072 KB
testcase_16 AC 255 ms
59,908 KB
testcase_17 AC 259 ms
60,388 KB
testcase_18 AC 256 ms
59,656 KB
testcase_19 AC 262 ms
60,620 KB
testcase_20 AC 128 ms
55,644 KB
testcase_21 AC 128 ms
55,772 KB
testcase_22 AC 130 ms
55,908 KB
testcase_23 AC 130 ms
55,728 KB
testcase_24 AC 159 ms
55,656 KB
testcase_25 AC 179 ms
55,852 KB
testcase_26 AC 128 ms
55,812 KB
testcase_27 AC 127 ms
55,976 KB
testcase_28 AC 128 ms
55,808 KB
testcase_29 AC 220 ms
59,172 KB
testcase_30 AC 207 ms
58,424 KB
testcase_31 AC 130 ms
55,420 KB
testcase_32 AC 134 ms
55,768 KB
testcase_33 AC 128 ms
55,724 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 ans = 0;
    for(int i = 0; i < N; i++) {
      L -= w[i];
      if(L >= 0) {
        ans++;
      } else {
        break;
      }
    }
    System.out.println(ans);
  }
}
0