結果

問題 No.5 数字のブロック
ユーザー キョウチクキョウチク
提出日時 2022-05-19 16:39:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 223 ms / 5,000 ms
コード長 635 bytes
コンパイル時間 4,087 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 58,996 KB
最終ジャッジ日時 2023-10-18 23:56:43
合計ジャッジ時間 10,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,420 KB
testcase_01 AC 131 ms
57,468 KB
testcase_02 AC 133 ms
57,328 KB
testcase_03 AC 203 ms
58,240 KB
testcase_04 AC 177 ms
57,580 KB
testcase_05 AC 212 ms
58,824 KB
testcase_06 AC 202 ms
57,876 KB
testcase_07 AC 195 ms
57,968 KB
testcase_08 AC 199 ms
58,272 KB
testcase_09 AC 168 ms
57,556 KB
testcase_10 AC 210 ms
58,440 KB
testcase_11 AC 197 ms
58,264 KB
testcase_12 AC 204 ms
58,252 KB
testcase_13 AC 210 ms
58,360 KB
testcase_14 AC 131 ms
57,248 KB
testcase_15 AC 132 ms
57,508 KB
testcase_16 AC 215 ms
58,512 KB
testcase_17 AC 219 ms
58,996 KB
testcase_18 AC 214 ms
58,796 KB
testcase_19 AC 223 ms
58,252 KB
testcase_20 AC 129 ms
57,316 KB
testcase_21 AC 128 ms
56,996 KB
testcase_22 AC 128 ms
57,504 KB
testcase_23 AC 129 ms
57,376 KB
testcase_24 AC 140 ms
57,388 KB
testcase_25 AC 147 ms
57,572 KB
testcase_26 AC 129 ms
57,504 KB
testcase_27 AC 129 ms
57,524 KB
testcase_28 AC 129 ms
56,932 KB
testcase_29 AC 192 ms
57,564 KB
testcase_30 AC 176 ms
57,660 KB
testcase_31 AC 133 ms
57,480 KB
testcase_32 AC 131 ms
57,348 KB
testcase_33 AC 130 ms
56,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Test11 {
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String[] line;
    line=sc.nextLine().split(" ");
    int w=Integer.parseInt(line[0]);
    line=sc.nextLine().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=0,size=0;
    int[] block=new int[n];
    line=sc.nextLine().split(" ");
    for(int i=0;i<n;i++){
      block[i]=Integer.parseInt(line[i]);
    }
    Arrays.sort(block);
    for(int i=0;i<n;i++){
      size+=block[i];
      if(w<size){
        break;
      }
      m++;
    }
    String result=""+m;
    System.out.println(result);
  }
}
0