結果

問題 No.5 数字のブロック
ユーザー drump_teitokudrump_teitoku
提出日時 2017-12-22 14:57:49
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 749 bytes
コンパイル時間 2,164 ms
コンパイル使用メモリ 76,680 KB
実行使用メモリ 51,384 KB
最終ジャッジ日時 2024-05-10 02:53:43
合計ジャッジ時間 6,082 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
36,540 KB
testcase_01 AC 55 ms
36,700 KB
testcase_02 AC 54 ms
37,100 KB
testcase_03 AC 96 ms
39,664 KB
testcase_04 AC 85 ms
38,520 KB
testcase_05 AC 106 ms
40,120 KB
testcase_06 AC 92 ms
38,688 KB
testcase_07 AC 96 ms
38,184 KB
testcase_08 AC 97 ms
39,028 KB
testcase_09 AC 75 ms
38,204 KB
testcase_10 AC 113 ms
40,160 KB
testcase_11 AC 87 ms
38,460 KB
testcase_12 AC 91 ms
39,504 KB
testcase_13 AC 102 ms
39,300 KB
testcase_14 AC 55 ms
36,912 KB
testcase_15 AC 56 ms
36,848 KB
testcase_16 AC 103 ms
39,972 KB
testcase_17 AC 123 ms
40,512 KB
testcase_18 AC 122 ms
39,632 KB
testcase_19 AC 117 ms
40,644 KB
testcase_20 RE -
testcase_21 AC 54 ms
37,024 KB
testcase_22 RE -
testcase_23 AC 55 ms
36,988 KB
testcase_24 AC 55 ms
36,960 KB
testcase_25 AC 58 ms
37,168 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 96 ms
38,772 KB
testcase_30 AC 84 ms
38,112 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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 < L;result++){
			sum+=w.get(result);
			if(sum > L){break;}
		}
		System.out.println(result);
	}

}
0