結果

問題 No.5 数字のブロック
ユーザー リチウムリチウム
提出日時 2014-11-21 21:21:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 471 bytes
コンパイル時間 2,269 ms
コンパイル使用メモリ 74,324 KB
実行使用メモリ 60,500 KB
最終ジャッジ日時 2024-04-29 00:25:13
合計ジャッジ時間 9,887 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
54,104 KB
testcase_01 AC 132 ms
53,940 KB
testcase_02 AC 132 ms
53,748 KB
testcase_03 AC 244 ms
58,200 KB
testcase_04 AC 219 ms
57,236 KB
testcase_05 AC 252 ms
58,652 KB
testcase_06 AC 232 ms
57,784 KB
testcase_07 AC 227 ms
57,196 KB
testcase_08 AC 244 ms
58,408 KB
testcase_09 AC 203 ms
57,028 KB
testcase_10 AC 259 ms
57,996 KB
testcase_11 AC 229 ms
57,584 KB
testcase_12 AC 246 ms
58,136 KB
testcase_13 AC 251 ms
58,692 KB
testcase_14 AC 147 ms
54,124 KB
testcase_15 AC 158 ms
54,388 KB
testcase_16 AC 256 ms
60,500 KB
testcase_17 AC 274 ms
58,516 KB
testcase_18 AC 266 ms
58,636 KB
testcase_19 AC 274 ms
58,800 KB
testcase_20 AC 133 ms
53,964 KB
testcase_21 AC 134 ms
54,052 KB
testcase_22 AC 129 ms
54,336 KB
testcase_23 AC 132 ms
54,392 KB
testcase_24 AC 157 ms
54,456 KB
testcase_25 AC 186 ms
54,368 KB
testcase_26 AC 135 ms
54,232 KB
testcase_27 AC 134 ms
54,080 KB
testcase_28 AC 132 ms
54,428 KB
testcase_29 AC 221 ms
57,164 KB
testcase_30 AC 205 ms
56,652 KB
testcase_31 AC 131 ms
54,112 KB
testcase_32 AC 133 ms
53,884 KB
testcase_33 AC 133 ms
54,244 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;
	  int sum=0;
	  int i=0;
	  while(i<n){
		  if(L-sum>=w[i]){
			  sum+=w[i];
			  ans++;
			  if(sum>=L)break;
		  }
		  i++;
	  }
	  System.out.println(ans);
  }}
0