結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,856 KB
testcase_01 AC 130 ms
55,704 KB
testcase_02 RE -
testcase_03 AC 243 ms
59,432 KB
testcase_04 AC 219 ms
59,276 KB
testcase_05 AC 252 ms
60,184 KB
testcase_06 AC 221 ms
59,708 KB
testcase_07 AC 227 ms
59,720 KB
testcase_08 AC 243 ms
59,840 KB
testcase_09 AC 210 ms
58,408 KB
testcase_10 AC 259 ms
60,672 KB
testcase_11 AC 238 ms
59,180 KB
testcase_12 AC 251 ms
60,952 KB
testcase_13 AC 256 ms
59,988 KB
testcase_14 AC 142 ms
55,636 KB
testcase_15 AC 164 ms
56,056 KB
testcase_16 AC 254 ms
60,352 KB
testcase_17 AC 266 ms
60,864 KB
testcase_18 AC 266 ms
60,924 KB
testcase_19 AC 263 ms
60,096 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 129 ms
55,512 KB
testcase_24 AC 159 ms
55,940 KB
testcase_25 AC 189 ms
56,092 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 223 ms
59,776 KB
testcase_30 AC 205 ms
58,640 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);

		while(stdIn.hasNext()){
			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