結果

問題 No.5 数字のブロック
ユーザー FpmpAmpmFpmpAmpm
提出日時 2016-10-22 12:18:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 300 ms / 5,000 ms
コード長 747 bytes
コンパイル時間 2,639 ms
コンパイル使用メモリ 88,228 KB
実行使用メモリ 47,944 KB
最終ジャッジ日時 2024-04-29 08:29:10
合計ジャッジ時間 10,198 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
41,188 KB
testcase_01 AC 118 ms
41,264 KB
testcase_02 AC 106 ms
41,040 KB
testcase_03 AC 229 ms
46,872 KB
testcase_04 AC 219 ms
45,716 KB
testcase_05 AC 253 ms
47,276 KB
testcase_06 AC 224 ms
46,248 KB
testcase_07 AC 217 ms
45,984 KB
testcase_08 AC 240 ms
46,012 KB
testcase_09 AC 203 ms
43,272 KB
testcase_10 AC 272 ms
47,800 KB
testcase_11 AC 223 ms
46,880 KB
testcase_12 AC 250 ms
46,848 KB
testcase_13 AC 268 ms
46,948 KB
testcase_14 AC 144 ms
41,292 KB
testcase_15 AC 164 ms
42,000 KB
testcase_16 AC 266 ms
47,592 KB
testcase_17 AC 299 ms
47,744 KB
testcase_18 AC 292 ms
47,688 KB
testcase_19 AC 300 ms
47,944 KB
testcase_20 AC 135 ms
41,276 KB
testcase_21 AC 134 ms
41,172 KB
testcase_22 AC 134 ms
41,448 KB
testcase_23 AC 135 ms
41,348 KB
testcase_24 AC 170 ms
41,804 KB
testcase_25 AC 192 ms
41,900 KB
testcase_26 AC 137 ms
41,452 KB
testcase_27 AC 133 ms
41,432 KB
testcase_28 AC 133 ms
40,988 KB
testcase_29 AC 246 ms
46,372 KB
testcase_30 AC 218 ms
43,924 KB
testcase_31 AC 133 ms
41,048 KB
testcase_32 AC 131 ms
41,540 KB
testcase_33 AC 132 ms
41,432 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