結果

問題 No.5 数字のブロック
ユーザー jimanojimano
提出日時 2015-12-27 16:47:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 562 bytes
コンパイル時間 3,460 ms
コンパイル使用メモリ 75,072 KB
実行使用メモリ 47,484 KB
最終ジャッジ日時 2024-04-29 06:44:32
合計ジャッジ時間 10,890 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
40,048 KB
testcase_01 AC 131 ms
41,288 KB
testcase_02 AC 131 ms
41,160 KB
testcase_03 AC 230 ms
45,800 KB
testcase_04 AC 227 ms
45,704 KB
testcase_05 AC 258 ms
46,956 KB
testcase_06 AC 232 ms
46,068 KB
testcase_07 AC 227 ms
46,092 KB
testcase_08 AC 250 ms
46,196 KB
testcase_09 AC 209 ms
43,524 KB
testcase_10 AC 260 ms
47,324 KB
testcase_11 AC 223 ms
45,464 KB
testcase_12 AC 249 ms
46,772 KB
testcase_13 AC 256 ms
46,988 KB
testcase_14 AC 141 ms
41,156 KB
testcase_15 AC 162 ms
41,532 KB
testcase_16 AC 260 ms
46,736 KB
testcase_17 AC 271 ms
47,336 KB
testcase_18 AC 264 ms
47,392 KB
testcase_19 AC 274 ms
47,484 KB
testcase_20 AC 127 ms
41,484 KB
testcase_21 AC 115 ms
40,024 KB
testcase_22 AC 132 ms
41,488 KB
testcase_23 AC 129 ms
41,032 KB
testcase_24 AC 159 ms
41,776 KB
testcase_25 AC 177 ms
41,736 KB
testcase_26 AC 124 ms
41,076 KB
testcase_27 AC 114 ms
40,160 KB
testcase_28 AC 131 ms
41,496 KB
testcase_29 AC 220 ms
45,628 KB
testcase_30 AC 201 ms
43,808 KB
testcase_31 AC 128 ms
41,348 KB
testcase_32 AC 126 ms
40,952 KB
testcase_33 AC 129 ms
41,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class No05 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int cntBlk = sc.nextInt();
		
		int[] widthOfBlk = new int[cntBlk];
		for(int i = 0; i < widthOfBlk.length; i++){
			widthOfBlk[i] =  sc.nextInt();
		}
		System.out.println(cnt(widthOfBlk, length));
	}
	
	static int cnt(int[] w, int l){
		int cnt = 0;
		Arrays.sort(w);
		for(int w1 : w){
			int tmp = l - w1;
			if(tmp >= 0){
				l = tmp;
				cnt++;
			}
		}
		return cnt;
	}
}
0