結果

問題 No.5 数字のブロック
ユーザー Koketti1Koketti1
提出日時 2017-02-04 14:45:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 257 ms / 5,000 ms
コード長 530 bytes
コンパイル時間 4,000 ms
コンパイル使用メモリ 73,256 KB
実行使用メモリ 60,764 KB
最終ジャッジ日時 2023-08-11 17:05:07
合計ジャッジ時間 11,831 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,064 KB
testcase_01 AC 121 ms
56,192 KB
testcase_02 AC 121 ms
55,792 KB
testcase_03 AC 228 ms
60,232 KB
testcase_04 AC 210 ms
58,912 KB
testcase_05 AC 242 ms
60,764 KB
testcase_06 AC 224 ms
59,340 KB
testcase_07 AC 214 ms
59,296 KB
testcase_08 AC 239 ms
59,716 KB
testcase_09 AC 196 ms
58,392 KB
testcase_10 AC 243 ms
60,352 KB
testcase_11 AC 215 ms
59,432 KB
testcase_12 AC 235 ms
60,084 KB
testcase_13 AC 243 ms
60,024 KB
testcase_14 AC 137 ms
56,528 KB
testcase_15 AC 147 ms
56,036 KB
testcase_16 AC 245 ms
60,284 KB
testcase_17 AC 257 ms
60,592 KB
testcase_18 AC 247 ms
60,388 KB
testcase_19 AC 251 ms
60,180 KB
testcase_20 AC 123 ms
56,136 KB
testcase_21 AC 124 ms
55,764 KB
testcase_22 AC 125 ms
55,784 KB
testcase_23 AC 122 ms
55,904 KB
testcase_24 AC 149 ms
56,052 KB
testcase_25 AC 170 ms
56,312 KB
testcase_26 AC 122 ms
56,044 KB
testcase_27 AC 125 ms
56,036 KB
testcase_28 AC 126 ms
55,720 KB
testcase_29 AC 218 ms
59,828 KB
testcase_30 AC 195 ms
58,588 KB
testcase_31 AC 125 ms
56,020 KB
testcase_32 AC 122 ms
56,072 KB
testcase_33 AC 124 ms
55,676 KB
権限があれば一括ダウンロードができます

ソースコード

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);
		for(int i = 0;i < N;i++){
			sum += a[count];
			count++;
			if(sum>L){
				break;
			}
		}
		if(sum>L){
			count -= 1;
		}
		System.out.println(count);
		
		scanner.close();
	}
}
0