結果

問題 No.5 数字のブロック
ユーザー AoiroFukurouAoiroFukurou
提出日時 2016-05-19 13:50:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 366 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 3,987 ms
コンパイル使用メモリ 71,424 KB
実行使用メモリ 60,536 KB
最終ジャッジ日時 2023-08-11 15:05:22
合計ジャッジ時間 12,864 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,548 KB
testcase_01 AC 126 ms
55,760 KB
testcase_02 AC 125 ms
55,388 KB
testcase_03 AC 317 ms
60,124 KB
testcase_04 AC 290 ms
59,644 KB
testcase_05 AC 348 ms
59,820 KB
testcase_06 AC 301 ms
59,932 KB
testcase_07 AC 271 ms
59,760 KB
testcase_08 AC 315 ms
60,076 KB
testcase_09 AC 213 ms
58,784 KB
testcase_10 AC 324 ms
60,128 KB
testcase_11 AC 263 ms
59,880 KB
testcase_12 AC 321 ms
59,976 KB
testcase_13 AC 345 ms
59,932 KB
testcase_14 AC 140 ms
55,472 KB
testcase_15 AC 161 ms
55,984 KB
testcase_16 AC 310 ms
60,536 KB
testcase_17 AC 341 ms
59,724 KB
testcase_18 AC 366 ms
60,016 KB
testcase_19 AC 346 ms
59,820 KB
testcase_20 AC 125 ms
55,540 KB
testcase_21 AC 124 ms
55,616 KB
testcase_22 AC 125 ms
55,508 KB
testcase_23 AC 127 ms
55,196 KB
testcase_24 AC 153 ms
55,484 KB
testcase_25 AC 189 ms
55,896 KB
testcase_26 AC 126 ms
55,472 KB
testcase_27 AC 126 ms
55,844 KB
testcase_28 AC 127 ms
55,640 KB
testcase_29 AC 283 ms
59,892 KB
testcase_30 AC 224 ms
58,352 KB
testcase_31 AC 124 ms
55,208 KB
testcase_32 AC 126 ms
55,576 KB
testcase_33 AC 126 ms
55,396 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