結果

問題 No.5 数字のブロック
ユーザー drump_teitokudrump_teitoku
提出日時 2017-12-22 15:00:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 73,636 KB
実行使用メモリ 52,912 KB
最終ジャッジ日時 2023-08-11 17:59:12
合計ジャッジ時間 5,920 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,420 KB
testcase_01 AC 44 ms
49,512 KB
testcase_02 AC 44 ms
49,544 KB
testcase_03 AC 80 ms
52,232 KB
testcase_04 AC 77 ms
51,672 KB
testcase_05 AC 93 ms
52,712 KB
testcase_06 AC 83 ms
52,304 KB
testcase_07 AC 77 ms
52,120 KB
testcase_08 AC 85 ms
52,376 KB
testcase_09 AC 60 ms
50,924 KB
testcase_10 AC 98 ms
52,564 KB
testcase_11 AC 75 ms
51,724 KB
testcase_12 AC 87 ms
52,912 KB
testcase_13 AC 92 ms
52,596 KB
testcase_14 AC 46 ms
49,616 KB
testcase_15 AC 47 ms
49,500 KB
testcase_16 AC 89 ms
52,532 KB
testcase_17 AC 97 ms
52,900 KB
testcase_18 AC 96 ms
52,720 KB
testcase_19 AC 112 ms
51,132 KB
testcase_20 AC 45 ms
49,368 KB
testcase_21 AC 45 ms
49,464 KB
testcase_22 AC 43 ms
47,876 KB
testcase_23 AC 44 ms
49,436 KB
testcase_24 AC 47 ms
49,756 KB
testcase_25 AC 52 ms
49,600 KB
testcase_26 AC 44 ms
49,432 KB
testcase_27 AC 44 ms
49,428 KB
testcase_28 AC 44 ms
49,356 KB
testcase_29 AC 74 ms
51,568 KB
testcase_30 AC 66 ms
51,784 KB
testcase_31 AC 44 ms
51,816 KB
testcase_32 AC 45 ms
49,320 KB
testcase_33 AC 44 ms
49,608 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