結果

問題 No.5 数字のブロック
ユーザー doyazaki012doyazaki012
提出日時 2015-04-24 17:07:38
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 562 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 72,368 KB
実行使用メモリ 60,512 KB
最終ジャッジ日時 2023-09-18 08:53:03
合計ジャッジ時間 12,221 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,444 KB
testcase_01 AC 127 ms
55,768 KB
testcase_02 RE -
testcase_03 AC 376 ms
60,216 KB
testcase_04 AC 315 ms
60,320 KB
testcase_05 AC 442 ms
60,432 KB
testcase_06 AC 344 ms
60,064 KB
testcase_07 AC 320 ms
60,124 KB
testcase_08 AC 386 ms
59,756 KB
testcase_09 AC 229 ms
58,556 KB
testcase_10 AC 458 ms
59,692 KB
testcase_11 AC 314 ms
60,224 KB
testcase_12 AC 367 ms
60,000 KB
testcase_13 AC 414 ms
60,244 KB
testcase_14 AC 141 ms
55,592 KB
testcase_15 AC 156 ms
56,112 KB
testcase_16 AC 426 ms
60,080 KB
testcase_17 AC 495 ms
60,512 KB
testcase_18 AC 475 ms
58,256 KB
testcase_19 AC 529 ms
60,480 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 128 ms
55,660 KB
testcase_24 AC 155 ms
56,008 KB
testcase_25 AC 199 ms
56,476 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 315 ms
59,960 KB
testcase_30 AC 256 ms
59,216 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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();
			}

			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