結果

問題 No.5 数字のブロック
ユーザー doyazaki012doyazaki012
提出日時 2015-04-24 17:38:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 72,184 KB
実行使用メモリ 60,524 KB
最終ジャッジ日時 2023-09-18 09:01:41
合計ジャッジ時間 9,390 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 121 ms
53,724 KB
testcase_02 AC 125 ms
56,312 KB
testcase_03 AC 228 ms
59,748 KB
testcase_04 AC 210 ms
59,600 KB
testcase_05 AC 238 ms
60,160 KB
testcase_06 AC 219 ms
60,140 KB
testcase_07 AC 210 ms
57,212 KB
testcase_08 AC 228 ms
60,012 KB
testcase_09 AC 192 ms
58,612 KB
testcase_10 AC 239 ms
60,224 KB
testcase_11 AC 214 ms
59,308 KB
testcase_12 AC 233 ms
59,580 KB
testcase_13 AC 241 ms
59,684 KB
testcase_14 AC 131 ms
55,984 KB
testcase_15 AC 143 ms
56,268 KB
testcase_16 AC 237 ms
60,124 KB
testcase_17 AC 246 ms
60,128 KB
testcase_18 AC 246 ms
60,524 KB
testcase_19 AC 248 ms
60,408 KB
testcase_20 AC 118 ms
55,912 KB
testcase_21 AC 120 ms
56,144 KB
testcase_22 AC 121 ms
55,788 KB
testcase_23 AC 123 ms
55,856 KB
testcase_24 AC 147 ms
56,132 KB
testcase_25 AC 178 ms
56,616 KB
testcase_26 AC 121 ms
55,820 KB
testcase_27 AC 120 ms
55,540 KB
testcase_28 AC 121 ms
54,232 KB
testcase_29 AC 209 ms
59,360 KB
testcase_30 AC 194 ms
58,440 KB
testcase_31 AC 122 ms
55,916 KB
testcase_32 AC 121 ms
55,604 KB
testcase_33 AC 123 ms
55,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Yuki5{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);

	
		int l = stdIn.nextInt();
		int n = stdIn.nextInt();
		int[] w = new int[n]; 
		for(int i=0;i<n;i++){
			w[i] = stdIn.nextInt();
		}

		Arrays.sort(w);
			/*for(int i=0;i<n-1;i++){
				for(int j=n-1;j>i;j--){
					if(w[j]<w[j-1]){
						int box = w[j];
						w[j] = w[j-1];
						w[j-1] = box;
					}
				}
			}*/
		int k=0;
		int sum = 0;
		while(sum<=l){
			sum+=w[k];
			k++;
			if(k==n){
				k++;
				break;
			}
		}

		System.out.println(k-1);
		
	}
}
0