結果

問題 No.5 数字のブロック
ユーザー asahi32942398asahi32942398
提出日時 2018-04-28 14:23:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 277 ms / 5,000 ms
コード長 447 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 75,016 KB
実行使用メモリ 47,716 KB
最終ジャッジ日時 2024-04-29 09:46:59
合計ジャッジ時間 9,890 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,536 KB
testcase_01 AC 130 ms
41,424 KB
testcase_02 AC 132 ms
41,064 KB
testcase_03 AC 245 ms
46,372 KB
testcase_04 AC 225 ms
45,592 KB
testcase_05 AC 261 ms
47,164 KB
testcase_06 AC 231 ms
46,116 KB
testcase_07 AC 235 ms
45,696 KB
testcase_08 AC 250 ms
46,304 KB
testcase_09 AC 211 ms
43,548 KB
testcase_10 AC 263 ms
46,808 KB
testcase_11 AC 225 ms
46,268 KB
testcase_12 AC 262 ms
46,724 KB
testcase_13 AC 261 ms
46,572 KB
testcase_14 AC 147 ms
41,192 KB
testcase_15 AC 162 ms
41,548 KB
testcase_16 AC 263 ms
46,540 KB
testcase_17 AC 274 ms
47,468 KB
testcase_18 AC 277 ms
47,716 KB
testcase_19 AC 273 ms
47,384 KB
testcase_20 AC 133 ms
41,048 KB
testcase_21 AC 121 ms
39,952 KB
testcase_22 AC 133 ms
41,528 KB
testcase_23 AC 132 ms
41,248 KB
testcase_24 AC 172 ms
41,756 KB
testcase_25 AC 187 ms
41,992 KB
testcase_26 AC 133 ms
41,372 KB
testcase_27 AC 136 ms
41,116 KB
testcase_28 AC 135 ms
41,268 KB
testcase_29 AC 226 ms
45,592 KB
testcase_30 AC 215 ms
43,868 KB
testcase_31 AC 133 ms
41,368 KB
testcase_32 AC 135 ms
41,552 KB
testcase_33 AC 118 ms
39,852 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 bn = sc.nextInt(); 
int[] bw = new int[bn];
int sum=0;
int answer=0;
for(int i=0;i<bn;i++){
  bw[i] = sc.nextInt(); 
}
Arrays.sort(bw);
for(int i=1;i<=bn;i++){
     sum+=bw[i-1];
  if(L>=sum){
    if(i==bn){
    answer = bn;
    }
  }else{
  answer = i-1;
  break;
  }
}
System.out.println(answer);
}
}
0