結果

問題 No.5 数字のブロック
ユーザー Koketti1Koketti1
提出日時 2017-02-04 14:28:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 71,816 KB
実行使用メモリ 61,024 KB
最終ジャッジ日時 2023-08-25 20:10:52
合計ジャッジ時間 10,524 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,008 KB
testcase_01 AC 122 ms
56,228 KB
testcase_02 WA -
testcase_03 AC 219 ms
59,552 KB
testcase_04 AC 211 ms
59,008 KB
testcase_05 WA -
testcase_06 AC 222 ms
59,676 KB
testcase_07 AC 217 ms
59,008 KB
testcase_08 AC 221 ms
57,952 KB
testcase_09 AC 198 ms
58,348 KB
testcase_10 AC 251 ms
60,764 KB
testcase_11 AC 220 ms
60,056 KB
testcase_12 AC 240 ms
59,996 KB
testcase_13 AC 244 ms
59,988 KB
testcase_14 AC 141 ms
55,840 KB
testcase_15 WA -
testcase_16 AC 248 ms
60,200 KB
testcase_17 AC 257 ms
60,764 KB
testcase_18 AC 263 ms
61,024 KB
testcase_19 AC 261 ms
60,032 KB
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 125 ms
57,792 KB
testcase_24 AC 150 ms
56,188 KB
testcase_25 AC 179 ms
56,628 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.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int sum = 0;
		int count = 0;
		int L = scanner.nextInt();
		int N = scanner.nextInt();
		int a[] = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = scanner.nextInt();
		}
		Arrays.sort(a);
		while(sum<L){
			sum += a[count];
			count++;
		}
		
		System.out.println(count-1);
		
		scanner.close();
	}
}
0