結果

問題 No.5 数字のブロック
ユーザー barrett114514barrett114514
提出日時 2017-07-21 23:14:45
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 473 bytes
コンパイル時間 3,747 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 49,124 KB
最終ジャッジ日時 2024-04-17 10:06:37
合計ジャッジ時間 10,316 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,096 KB
testcase_01 AC 123 ms
43,164 KB
testcase_02 AC 117 ms
42,928 KB
testcase_03 AC 239 ms
47,860 KB
testcase_04 AC 217 ms
47,780 KB
testcase_05 AC 239 ms
49,124 KB
testcase_06 AC 227 ms
47,968 KB
testcase_07 AC 204 ms
47,768 KB
testcase_08 AC 219 ms
48,256 KB
testcase_09 AC 193 ms
45,972 KB
testcase_10 AC 244 ms
47,996 KB
testcase_11 AC 214 ms
47,600 KB
testcase_12 AC 229 ms
48,316 KB
testcase_13 AC 248 ms
48,788 KB
testcase_14 AC 148 ms
43,280 KB
testcase_15 AC 160 ms
43,668 KB
testcase_16 AC 243 ms
48,616 KB
testcase_17 AC 255 ms
48,700 KB
testcase_18 AC 255 ms
48,972 KB
testcase_19 AC 266 ms
48,804 KB
testcase_20 RE -
testcase_21 AC 134 ms
42,992 KB
testcase_22 AC 126 ms
41,168 KB
testcase_23 AC 128 ms
41,712 KB
testcase_24 AC 163 ms
41,860 KB
testcase_25 AC 168 ms
42,148 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 218 ms
45,576 KB
testcase_30 AC 198 ms
43,464 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class NumberBlocks {

	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];
		
		for(int i = 0;i < N; i++){
			W[i] = sc.nextInt();
		}
		Arrays.sort(W);
		
		for(int i = 0;L > 0;){
			L -= W[i];
			i ++;

			if(L <= 0){
				if(L < 0){
				i = i - 1;
				}
				
				System.out.println(i);
				break;
			}
		}

	}

}
0