結果

問題 No.5 数字のブロック
ユーザー discoNekodiscoNeko
提出日時 2016-04-28 23:44:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 75,536 KB
実行使用メモリ 40,200 KB
最終ジャッジ日時 2024-04-29 07:12:01
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,844 KB
testcase_01 AC 52 ms
36,720 KB
testcase_02 AC 52 ms
37,176 KB
testcase_03 AC 82 ms
38,464 KB
testcase_04 AC 70 ms
38,268 KB
testcase_05 AC 99 ms
39,672 KB
testcase_06 AC 84 ms
38,608 KB
testcase_07 AC 84 ms
38,560 KB
testcase_08 AC 89 ms
39,140 KB
testcase_09 AC 60 ms
37,068 KB
testcase_10 AC 87 ms
39,176 KB
testcase_11 AC 80 ms
38,316 KB
testcase_12 AC 100 ms
39,476 KB
testcase_13 AC 90 ms
39,008 KB
testcase_14 AC 53 ms
36,896 KB
testcase_15 AC 52 ms
36,856 KB
testcase_16 AC 103 ms
39,824 KB
testcase_17 AC 104 ms
39,860 KB
testcase_18 AC 95 ms
40,200 KB
testcase_19 AC 94 ms
40,060 KB
testcase_20 AC 51 ms
37,180 KB
testcase_21 AC 51 ms
37,276 KB
testcase_22 AC 52 ms
36,856 KB
testcase_23 AC 52 ms
37,160 KB
testcase_24 AC 54 ms
36,952 KB
testcase_25 AC 55 ms
37,068 KB
testcase_26 AC 55 ms
36,980 KB
testcase_27 AC 52 ms
36,812 KB
testcase_28 AC 51 ms
36,960 KB
testcase_29 AC 69 ms
38,264 KB
testcase_30 AC 67 ms
38,056 KB
testcase_31 AC 52 ms
36,672 KB
testcase_32 AC 50 ms
36,916 KB
testcase_33 AC 54 ms
37,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int l = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		int[] w = new int[n];
		for(int i = 0; i < n; i++){
			w[i] = Integer.parseInt(str[i]);
		}
		Arrays.sort(w);
		int sum = 0;
		for(int i = 0; i < n; i++){
			sum += w[i];
			if(sum>l){
				sb.append(i);
				System.out.println(sb);
				return;
			}
		}
		sb.append(n);
		System.out.println(sb);
	}
}
0