結果

問題 No.5 数字のブロック
ユーザー GBGB
提出日時 2018-04-09 14:29:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 232 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 75,048 KB
実行使用メモリ 46,616 KB
最終ジャッジ日時 2024-04-29 09:43:52
合計ジャッジ時間 8,791 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,552 KB
testcase_01 AC 128 ms
41,940 KB
testcase_02 AC 127 ms
41,108 KB
testcase_03 AC 199 ms
44,628 KB
testcase_04 AC 199 ms
43,480 KB
testcase_05 AC 213 ms
45,672 KB
testcase_06 AC 199 ms
44,424 KB
testcase_07 AC 190 ms
43,564 KB
testcase_08 AC 200 ms
44,056 KB
testcase_09 AC 174 ms
42,408 KB
testcase_10 AC 207 ms
46,160 KB
testcase_11 AC 190 ms
43,600 KB
testcase_12 AC 206 ms
44,976 KB
testcase_13 AC 212 ms
45,628 KB
testcase_14 AC 132 ms
41,444 KB
testcase_15 AC 139 ms
41,672 KB
testcase_16 AC 206 ms
44,996 KB
testcase_17 AC 226 ms
46,616 KB
testcase_18 AC 232 ms
46,384 KB
testcase_19 AC 229 ms
46,560 KB
testcase_20 AC 127 ms
41,108 KB
testcase_21 AC 135 ms
41,112 KB
testcase_22 AC 131 ms
40,940 KB
testcase_23 AC 132 ms
41,368 KB
testcase_24 AC 153 ms
41,524 KB
testcase_25 AC 169 ms
41,832 KB
testcase_26 AC 127 ms
41,280 KB
testcase_27 AC 113 ms
41,388 KB
testcase_28 AC 110 ms
41,316 KB
testcase_29 AC 180 ms
43,620 KB
testcase_30 AC 177 ms
42,512 KB
testcase_31 AC 126 ms
41,080 KB
testcase_32 AC 122 ms
41,196 KB
testcase_33 AC 122 ms
41,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args) {

    Scanner scan=new Scanner(System.in);
    int l=Integer.parseInt(scan.next());
    int n=Integer.parseInt(scan.next());
    int[] w=new int[n];
    for(int i=0;i<w.length;i++){
      w[i]=Integer.parseInt(scan.next());
    }

    Arrays.sort(w);

    int length=0;
    int count=0;
    for(int i=0;i<w.length;i++){
      length+=w[i];
      if(length<=l){
        count++;
      }else{
        break;
      }
    }

    System.out.println(count);
  }
}
0