結果

問題 No.5 数字のブロック
ユーザー doyazaki012doyazaki012
提出日時 2015-04-24 17:29:26
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 555 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 72,684 KB
実行使用メモリ 60,700 KB
最終ジャッジ日時 2023-09-18 09:00:42
合計ジャッジ時間 9,895 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,772 KB
testcase_01 AC 129 ms
55,884 KB
testcase_02 RE -
testcase_03 AC 237 ms
60,032 KB
testcase_04 AC 212 ms
59,188 KB
testcase_05 AC 256 ms
60,456 KB
testcase_06 AC 220 ms
59,488 KB
testcase_07 AC 226 ms
59,300 KB
testcase_08 AC 235 ms
60,476 KB
testcase_09 AC 202 ms
58,504 KB
testcase_10 AC 257 ms
60,700 KB
testcase_11 AC 227 ms
59,552 KB
testcase_12 AC 243 ms
59,916 KB
testcase_13 AC 247 ms
59,996 KB
testcase_14 AC 143 ms
55,992 KB
testcase_15 AC 157 ms
55,816 KB
testcase_16 AC 252 ms
60,216 KB
testcase_17 AC 260 ms
60,468 KB
testcase_18 AC 262 ms
60,508 KB
testcase_19 AC 273 ms
60,192 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 130 ms
55,700 KB
testcase_24 AC 158 ms
55,964 KB
testcase_25 AC 192 ms
56,088 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 223 ms
59,228 KB
testcase_30 AC 206 ms
58,728 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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++;
			}

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