結果

問題 No.5 数字のブロック
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 00:48:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 368 ms / 5,000 ms
コード長 453 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 74,076 KB
実行使用メモリ 47,532 KB
最終ジャッジ日時 2024-04-29 09:37:10
合計ジャッジ時間 10,200 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,032 KB
testcase_01 AC 138 ms
41,244 KB
testcase_02 AC 142 ms
41,148 KB
testcase_03 AC 255 ms
46,224 KB
testcase_04 AC 240 ms
45,712 KB
testcase_05 AC 271 ms
46,436 KB
testcase_06 AC 252 ms
46,240 KB
testcase_07 AC 241 ms
45,408 KB
testcase_08 AC 249 ms
47,020 KB
testcase_09 AC 216 ms
43,720 KB
testcase_10 AC 267 ms
47,128 KB
testcase_11 AC 243 ms
46,176 KB
testcase_12 AC 252 ms
46,556 KB
testcase_13 AC 275 ms
47,080 KB
testcase_14 AC 153 ms
41,388 KB
testcase_15 AC 163 ms
41,424 KB
testcase_16 AC 260 ms
46,264 KB
testcase_17 AC 280 ms
47,292 KB
testcase_18 AC 275 ms
47,012 KB
testcase_19 AC 368 ms
47,532 KB
testcase_20 AC 135 ms
41,084 KB
testcase_21 AC 137 ms
41,300 KB
testcase_22 AC 137 ms
41,384 KB
testcase_23 AC 138 ms
41,160 KB
testcase_24 AC 160 ms
41,704 KB
testcase_25 AC 194 ms
41,796 KB
testcase_26 AC 144 ms
41,312 KB
testcase_27 AC 142 ms
41,248 KB
testcase_28 AC 141 ms
41,184 KB
testcase_29 AC 234 ms
45,620 KB
testcase_30 AC 213 ms
43,764 KB
testcase_31 AC 135 ms
41,524 KB
testcase_32 AC 118 ms
40,216 KB
testcase_33 AC 134 ms
41,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int L = sc.nextInt();
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
		}
		Arrays.sort(ints);
		int count = 0;
		int length = 0;
		for (int i=0; i<n; i++) {
			length += ints[i];
			if (length <= L) {count++;}
			else {break;}
		}
		System.out.println(count);
	}
}
0