結果

問題 No.5 数字のブロック
ユーザー リチウムリチウム
提出日時 2014-11-21 21:20:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 71,644 KB
実行使用メモリ 60,976 KB
最終ジャッジ日時 2023-08-30 22:11:06
合計ジャッジ時間 9,992 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,160 KB
testcase_01 AC 124 ms
55,924 KB
testcase_02 WA -
testcase_03 AC 232 ms
59,528 KB
testcase_04 AC 215 ms
59,144 KB
testcase_05 WA -
testcase_06 AC 223 ms
59,640 KB
testcase_07 AC 222 ms
59,164 KB
testcase_08 AC 233 ms
59,680 KB
testcase_09 AC 198 ms
58,384 KB
testcase_10 AC 245 ms
60,420 KB
testcase_11 AC 219 ms
60,124 KB
testcase_12 AC 237 ms
59,332 KB
testcase_13 AC 248 ms
60,012 KB
testcase_14 AC 138 ms
56,076 KB
testcase_15 WA -
testcase_16 AC 244 ms
59,908 KB
testcase_17 AC 260 ms
60,976 KB
testcase_18 AC 255 ms
60,636 KB
testcase_19 AC 258 ms
60,672 KB
testcase_20 AC 123 ms
55,960 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 125 ms
56,116 KB
testcase_24 AC 151 ms
55,612 KB
testcase_25 AC 180 ms
55,856 KB
testcase_26 AC 125 ms
55,856 KB
testcase_27 AC 124 ms
55,928 KB
testcase_28 AC 124 ms
55,676 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 124 ms
55,940 KB
testcase_32 AC 125 ms
55,948 KB
testcase_33 AC 126 ms
56,268 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