結果

問題 No.5 数字のブロック
ユーザー FpmpAmpmFpmpAmpm
提出日時 2016-10-22 12:18:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 747 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 82,628 KB
実行使用メモリ 62,940 KB
最終ジャッジ日時 2023-08-11 16:40:34
合計ジャッジ時間 10,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,484 KB
testcase_01 AC 127 ms
55,448 KB
testcase_02 AC 126 ms
55,892 KB
testcase_03 AC 235 ms
59,380 KB
testcase_04 AC 230 ms
59,184 KB
testcase_05 AC 260 ms
62,940 KB
testcase_06 AC 240 ms
60,160 KB
testcase_07 AC 228 ms
59,416 KB
testcase_08 AC 235 ms
59,424 KB
testcase_09 AC 203 ms
58,352 KB
testcase_10 AC 269 ms
60,320 KB
testcase_11 AC 228 ms
59,908 KB
testcase_12 AC 243 ms
60,092 KB
testcase_13 AC 256 ms
60,596 KB
testcase_14 AC 143 ms
56,048 KB
testcase_15 AC 158 ms
55,860 KB
testcase_16 AC 254 ms
60,700 KB
testcase_17 AC 276 ms
61,104 KB
testcase_18 AC 271 ms
60,640 KB
testcase_19 AC 285 ms
60,740 KB
testcase_20 AC 129 ms
55,808 KB
testcase_21 AC 129 ms
55,728 KB
testcase_22 AC 130 ms
55,804 KB
testcase_23 AC 127 ms
53,792 KB
testcase_24 AC 147 ms
55,796 KB
testcase_25 AC 181 ms
56,376 KB
testcase_26 AC 127 ms
55,744 KB
testcase_27 AC 128 ms
55,700 KB
testcase_28 AC 124 ms
55,460 KB
testcase_29 AC 228 ms
59,496 KB
testcase_30 AC 204 ms
58,716 KB
testcase_31 AC 122 ms
55,712 KB
testcase_32 AC 123 ms
55,820 KB
testcase_33 AC 125 ms
57,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
    	int L = sc.nextInt();
    	int N = sc.nextInt();
    	
    	Integer[] W = new Integer[N];
    	List<Integer> list = new ArrayList<>();
    	
    	for (int i = 0;i < N;i++) {
    		W[i] = Integer.valueOf(sc.nextInt());
    	}
    	Collections.addAll(list,W);
    	list.sort((s1, s2) -> s1.compareTo(s2));
    	int sum =0;
    	int count = 0;
    	for (Integer I:list) {
    		sum += I;
    		if (0 <= L - sum) count++;
    	}
    	System.out.println(count);
    	
    	
    	
	}
}
0