結果

問題 No.5 数字のブロック
ユーザー barrett114514barrett114514
提出日時 2017-07-21 22:54:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 3,327 ms
コンパイル使用メモリ 74,696 KB
実行使用メモリ 60,900 KB
最終ジャッジ日時 2024-04-17 10:05:54
合計ジャッジ時間 10,512 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
41,536 KB
testcase_01 AC 129 ms
41,516 KB
testcase_02 WA -
testcase_03 AC 245 ms
46,688 KB
testcase_04 AC 217 ms
45,836 KB
testcase_05 WA -
testcase_06 AC 222 ms
46,552 KB
testcase_07 AC 209 ms
46,072 KB
testcase_08 AC 229 ms
46,716 KB
testcase_09 AC 195 ms
44,040 KB
testcase_10 AC 244 ms
47,240 KB
testcase_11 AC 219 ms
45,516 KB
testcase_12 AC 239 ms
47,260 KB
testcase_13 AC 236 ms
47,452 KB
testcase_14 AC 132 ms
41,876 KB
testcase_15 WA -
testcase_16 AC 252 ms
46,472 KB
testcase_17 AC 242 ms
47,756 KB
testcase_18 AC 239 ms
47,872 KB
testcase_19 AC 246 ms
47,640 KB
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 119 ms
41,608 KB
testcase_24 AC 140 ms
41,808 KB
testcase_25 AC 170 ms
42,016 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 WA -
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; i ++){
			L -= W[i];
			
			if(L < 0){
				if(i < 0){
				i --;
				}
				
				System.out.println(i);
				break;
			}
		}

	}

}
0