結果

問題 No.5 数字のブロック
ユーザー AoiroFukurouAoiroFukurou
提出日時 2016-05-19 13:50:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 385 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 3,299 ms
コンパイル使用メモリ 74,600 KB
実行使用メモリ 47,364 KB
最終ジャッジ日時 2024-04-29 07:16:13
合計ジャッジ時間 12,066 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,140 KB
testcase_01 AC 130 ms
41,020 KB
testcase_02 AC 128 ms
40,996 KB
testcase_03 AC 325 ms
46,804 KB
testcase_04 AC 279 ms
46,712 KB
testcase_05 AC 332 ms
46,732 KB
testcase_06 AC 280 ms
45,580 KB
testcase_07 AC 273 ms
46,684 KB
testcase_08 AC 314 ms
47,032 KB
testcase_09 AC 213 ms
43,372 KB
testcase_10 AC 357 ms
47,144 KB
testcase_11 AC 279 ms
46,724 KB
testcase_12 AC 333 ms
46,920 KB
testcase_13 AC 351 ms
46,916 KB
testcase_14 AC 142 ms
41,252 KB
testcase_15 AC 167 ms
41,700 KB
testcase_16 AC 355 ms
46,944 KB
testcase_17 AC 359 ms
47,280 KB
testcase_18 AC 385 ms
47,244 KB
testcase_19 AC 380 ms
47,364 KB
testcase_20 AC 115 ms
39,752 KB
testcase_21 AC 114 ms
40,284 KB
testcase_22 AC 128 ms
41,180 KB
testcase_23 AC 118 ms
40,032 KB
testcase_24 AC 157 ms
41,828 KB
testcase_25 AC 176 ms
42,172 KB
testcase_26 AC 127 ms
41,096 KB
testcase_27 AC 125 ms
41,156 KB
testcase_28 AC 129 ms
40,948 KB
testcase_29 AC 269 ms
46,576 KB
testcase_30 AC 218 ms
44,016 KB
testcase_31 AC 128 ms
41,328 KB
testcase_32 AC 126 ms
41,512 KB
testcase_33 AC 130 ms
41,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class No5 {
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];
	int tmp = 0;
	int c = 0;
	for(int i = 0; i < w.length; i++){
		w[i] = sc.nextInt();
	}
	for(int j = 1; j < w.length; j++){
		int tmp2 = w[j];
		int i = j - 1;
		while(i >= 0 && w[i] > tmp2){
			w[i + 1] = w[i];
			i--;
		}
		w[i + 1] = tmp2;
	}
	for(int i = 0; i < w.length; i++){
		if(L - tmp >= w[i]){
			tmp += w[i];
			c++;
		}else{
			break;
		}
	}
	System.out.println(c);
	sc.close();
}
}
0