結果

問題 No.5 数字のブロック
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-11 21:12:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 275 ms / 5,000 ms
コード長 468 bytes
コンパイル時間 2,340 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 47,472 KB
最終ジャッジ日時 2024-04-29 09:08:11
合計ジャッジ時間 9,939 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
41,512 KB
testcase_01 AC 128 ms
41,112 KB
testcase_02 AC 129 ms
41,160 KB
testcase_03 AC 251 ms
46,300 KB
testcase_04 AC 225 ms
45,516 KB
testcase_05 AC 258 ms
46,796 KB
testcase_06 AC 225 ms
46,096 KB
testcase_07 AC 225 ms
45,752 KB
testcase_08 AC 245 ms
45,812 KB
testcase_09 AC 213 ms
43,612 KB
testcase_10 AC 269 ms
46,756 KB
testcase_11 AC 241 ms
45,388 KB
testcase_12 AC 262 ms
46,516 KB
testcase_13 AC 274 ms
46,596 KB
testcase_14 AC 149 ms
41,440 KB
testcase_15 AC 162 ms
41,476 KB
testcase_16 AC 270 ms
46,732 KB
testcase_17 AC 275 ms
46,944 KB
testcase_18 AC 266 ms
47,472 KB
testcase_19 AC 271 ms
47,448 KB
testcase_20 AC 130 ms
41,120 KB
testcase_21 AC 131 ms
41,172 KB
testcase_22 AC 132 ms
41,324 KB
testcase_23 AC 116 ms
40,448 KB
testcase_24 AC 167 ms
41,816 KB
testcase_25 AC 177 ms
41,864 KB
testcase_26 AC 130 ms
41,104 KB
testcase_27 AC 140 ms
41,424 KB
testcase_28 AC 138 ms
41,124 KB
testcase_29 AC 232 ms
45,536 KB
testcase_30 AC 213 ms
43,872 KB
testcase_31 AC 137 ms
41,380 KB
testcase_32 AC 134 ms
41,240 KB
testcase_33 AC 119 ms
40,136 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