結果

問題 No.5 数字のブロック
ユーザー shinshin
提出日時 2022-05-12 18:24:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 227 ms / 5,000 ms
コード長 558 bytes
コンパイル時間 3,109 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 60,328 KB
最終ジャッジ日時 2023-09-27 17:59:23
合計ジャッジ時間 10,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
54,368 KB
testcase_01 AC 110 ms
55,816 KB
testcase_02 AC 110 ms
55,568 KB
testcase_03 AC 192 ms
58,740 KB
testcase_04 AC 183 ms
58,600 KB
testcase_05 AC 197 ms
59,636 KB
testcase_06 AC 188 ms
58,768 KB
testcase_07 AC 180 ms
58,764 KB
testcase_08 AC 188 ms
59,208 KB
testcase_09 AC 169 ms
56,632 KB
testcase_10 AC 212 ms
60,092 KB
testcase_11 AC 186 ms
58,636 KB
testcase_12 AC 197 ms
58,696 KB
testcase_13 AC 205 ms
60,324 KB
testcase_14 AC 119 ms
55,704 KB
testcase_15 AC 125 ms
56,004 KB
testcase_16 AC 206 ms
59,516 KB
testcase_17 AC 225 ms
60,328 KB
testcase_18 AC 224 ms
59,968 KB
testcase_19 AC 227 ms
60,128 KB
testcase_20 AC 109 ms
56,212 KB
testcase_21 AC 111 ms
55,856 KB
testcase_22 AC 110 ms
56,168 KB
testcase_23 AC 111 ms
56,004 KB
testcase_24 AC 130 ms
55,748 KB
testcase_25 AC 144 ms
56,336 KB
testcase_26 AC 109 ms
53,900 KB
testcase_27 AC 107 ms
55,816 KB
testcase_28 AC 108 ms
55,900 KB
testcase_29 AC 179 ms
58,972 KB
testcase_30 AC 170 ms
56,728 KB
testcase_31 AC 115 ms
56,416 KB
testcase_32 AC 109 ms
55,672 KB
testcase_33 AC 108 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class No5 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<Integer> W = new ArrayList<>();
		int L = Integer.parseInt(s.nextLine()),N = Integer.parseInt(s.nextLine()),i = 0,count = 0;
		for(i = 0;i < N;i++) {
			W.add(Integer.parseInt(s.next()));
		}
		s.close();
		
		i = 0;
		Collections.sort(W);
		
		for(int w : W) {
			L = L - w;
			if(L < 0) {
				break;
			}else {
				i++;
			}
		}

		System.out.println(i);
	}

}
0