結果

問題 No.5 数字のブロック
ユーザー Koketti1Koketti1
提出日時 2017-02-04 14:41:09
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 488 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 71,296 KB
実行使用メモリ 60,872 KB
最終ジャッジ日時 2023-08-25 20:11:03
合計ジャッジ時間 9,814 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,044 KB
testcase_01 AC 122 ms
56,024 KB
testcase_02 AC 119 ms
55,800 KB
testcase_03 AC 224 ms
59,604 KB
testcase_04 AC 207 ms
59,372 KB
testcase_05 AC 241 ms
60,224 KB
testcase_06 AC 226 ms
59,204 KB
testcase_07 AC 213 ms
59,088 KB
testcase_08 AC 226 ms
59,692 KB
testcase_09 AC 198 ms
58,160 KB
testcase_10 AC 255 ms
60,456 KB
testcase_11 AC 214 ms
59,892 KB
testcase_12 AC 235 ms
60,248 KB
testcase_13 AC 240 ms
59,876 KB
testcase_14 AC 137 ms
56,092 KB
testcase_15 AC 144 ms
56,044 KB
testcase_16 AC 238 ms
59,500 KB
testcase_17 AC 251 ms
60,216 KB
testcase_18 AC 245 ms
60,208 KB
testcase_19 AC 252 ms
60,872 KB
testcase_20 RE -
testcase_21 AC 122 ms
55,848 KB
testcase_22 AC 123 ms
56,204 KB
testcase_23 AC 122 ms
56,128 KB
testcase_24 AC 150 ms
55,724 KB
testcase_25 AC 177 ms
56,148 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 212 ms
58,888 KB
testcase_30 AC 193 ms
58,848 KB
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++;
		}
		if(sum>L){
			count -= 1;
		}
		System.out.println(count);
		
		scanner.close();
	}
}
0