結果

問題 No.5 数字のブロック
ユーザー discoNekodiscoNeko
提出日時 2016-04-28 23:44:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 2,520 ms
コンパイル使用メモリ 72,660 KB
実行使用メモリ 53,112 KB
最終ジャッジ日時 2023-08-11 15:00:06
合計ジャッジ時間 6,352 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,340 KB
testcase_01 AC 44 ms
49,596 KB
testcase_02 AC 43 ms
49,340 KB
testcase_03 AC 79 ms
51,720 KB
testcase_04 AC 69 ms
51,480 KB
testcase_05 AC 77 ms
50,152 KB
testcase_06 AC 70 ms
51,268 KB
testcase_07 AC 66 ms
51,268 KB
testcase_08 AC 78 ms
53,112 KB
testcase_09 AC 57 ms
50,272 KB
testcase_10 AC 79 ms
51,716 KB
testcase_11 AC 74 ms
51,560 KB
testcase_12 AC 91 ms
52,736 KB
testcase_13 AC 88 ms
52,820 KB
testcase_14 AC 46 ms
49,164 KB
testcase_15 AC 46 ms
49,420 KB
testcase_16 AC 93 ms
52,584 KB
testcase_17 AC 92 ms
52,760 KB
testcase_18 AC 94 ms
52,772 KB
testcase_19 AC 96 ms
52,900 KB
testcase_20 AC 44 ms
49,184 KB
testcase_21 AC 44 ms
49,248 KB
testcase_22 AC 46 ms
49,208 KB
testcase_23 AC 44 ms
49,168 KB
testcase_24 AC 47 ms
49,184 KB
testcase_25 AC 53 ms
49,260 KB
testcase_26 AC 45 ms
49,320 KB
testcase_27 AC 44 ms
49,076 KB
testcase_28 AC 44 ms
49,296 KB
testcase_29 AC 65 ms
51,332 KB
testcase_30 AC 57 ms
48,156 KB
testcase_31 AC 44 ms
49,248 KB
testcase_32 AC 44 ms
49,248 KB
testcase_33 AC 45 ms
49,252 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