結果

問題 No.5 数字のブロック
ユーザー drump_teitokudrump_teitoku
提出日時 2017-12-22 15:00:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 75,964 KB
実行使用メモリ 40,400 KB
最終ジャッジ日時 2024-04-29 09:31:42
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,692 KB
testcase_01 AC 52 ms
37,032 KB
testcase_02 AC 51 ms
37,040 KB
testcase_03 AC 95 ms
39,152 KB
testcase_04 AC 92 ms
38,432 KB
testcase_05 AC 104 ms
39,664 KB
testcase_06 AC 91 ms
38,696 KB
testcase_07 AC 80 ms
38,616 KB
testcase_08 AC 92 ms
39,012 KB
testcase_09 AC 78 ms
37,952 KB
testcase_10 AC 108 ms
39,928 KB
testcase_11 AC 81 ms
38,612 KB
testcase_12 AC 92 ms
38,708 KB
testcase_13 AC 102 ms
39,432 KB
testcase_14 AC 51 ms
36,568 KB
testcase_15 AC 55 ms
37,148 KB
testcase_16 AC 104 ms
39,760 KB
testcase_17 AC 107 ms
40,244 KB
testcase_18 AC 101 ms
39,304 KB
testcase_19 AC 121 ms
40,400 KB
testcase_20 AC 51 ms
36,856 KB
testcase_21 AC 52 ms
36,912 KB
testcase_22 AC 52 ms
36,656 KB
testcase_23 AC 52 ms
37,092 KB
testcase_24 AC 54 ms
37,060 KB
testcase_25 AC 54 ms
36,540 KB
testcase_26 AC 51 ms
36,844 KB
testcase_27 AC 51 ms
36,588 KB
testcase_28 AC 50 ms
36,680 KB
testcase_29 AC 79 ms
38,356 KB
testcase_30 AC 80 ms
38,040 KB
testcase_31 AC 51 ms
37,116 KB
testcase_32 AC 51 ms
36,800 KB
testcase_33 AC 50 ms
36,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int L = Integer.parseInt(br.readLine());
		int N = Integer.parseInt(br.readLine());
		String s[] = br.readLine().split(" ");
		ArrayList<Integer> w = new ArrayList<Integer>();
		for(int i=0;i<N;i++){
			w.add(Integer.parseInt(s[i]));
		}
		Collections.sort(w);
		int sum=0,result = 0;
		for(;result < N;result++){
			sum+=w.get(result);
			if(sum > L){break;}
		}
		System.out.println(result);
	}

}
0