結果

問題 No.5 数字のブロック
ユーザー リチウムリチウム
提出日時 2014-11-21 21:21:42
言語 Java19
(openjdk 21)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 471 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 73,088 KB
実行使用メモリ 60,884 KB
最終ジャッジ日時 2023-08-11 07:48:22
合計ジャッジ時間 9,682 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,972 KB
testcase_01 AC 126 ms
55,908 KB
testcase_02 AC 123 ms
55,588 KB
testcase_03 AC 234 ms
60,280 KB
testcase_04 AC 210 ms
59,188 KB
testcase_05 AC 241 ms
58,244 KB
testcase_06 AC 225 ms
59,496 KB
testcase_07 AC 215 ms
59,096 KB
testcase_08 AC 231 ms
59,872 KB
testcase_09 AC 194 ms
58,412 KB
testcase_10 AC 243 ms
59,920 KB
testcase_11 AC 219 ms
59,800 KB
testcase_12 AC 242 ms
60,572 KB
testcase_13 AC 253 ms
60,764 KB
testcase_14 AC 139 ms
55,908 KB
testcase_15 AC 150 ms
56,216 KB
testcase_16 AC 254 ms
60,472 KB
testcase_17 AC 256 ms
60,884 KB
testcase_18 AC 252 ms
60,876 KB
testcase_19 AC 272 ms
59,944 KB
testcase_20 AC 126 ms
55,836 KB
testcase_21 AC 126 ms
55,816 KB
testcase_22 AC 125 ms
55,816 KB
testcase_23 AC 125 ms
55,832 KB
testcase_24 AC 151 ms
56,028 KB
testcase_25 AC 178 ms
56,164 KB
testcase_26 AC 124 ms
55,832 KB
testcase_27 AC 124 ms
55,868 KB
testcase_28 AC 122 ms
55,836 KB
testcase_29 AC 208 ms
59,580 KB
testcase_30 AC 196 ms
58,136 KB
testcase_31 AC 123 ms
56,016 KB
testcase_32 AC 120 ms
55,824 KB
testcase_33 AC 123 ms
55,868 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