結果

問題 No.5 数字のブロック
ユーザー yun_appyun_app
提出日時 2016-05-09 12:17:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 926 bytes
コンパイル時間 2,532 ms
コンパイル使用メモリ 73,192 KB
実行使用メモリ 53,260 KB
最終ジャッジ日時 2023-08-11 15:02:47
合計ジャッジ時間 5,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,516 KB
testcase_01 AC 44 ms
49,456 KB
testcase_02 AC 43 ms
49,476 KB
testcase_03 AC 87 ms
52,280 KB
testcase_04 AC 74 ms
51,796 KB
testcase_05 AC 91 ms
52,628 KB
testcase_06 AC 82 ms
51,720 KB
testcase_07 AC 74 ms
52,128 KB
testcase_08 AC 84 ms
52,248 KB
testcase_09 AC 71 ms
51,436 KB
testcase_10 AC 94 ms
53,076 KB
testcase_11 AC 74 ms
52,008 KB
testcase_12 AC 87 ms
50,836 KB
testcase_13 AC 93 ms
51,924 KB
testcase_14 AC 46 ms
49,516 KB
testcase_15 AC 47 ms
49,344 KB
testcase_16 AC 104 ms
52,364 KB
testcase_17 AC 97 ms
53,128 KB
testcase_18 AC 92 ms
52,972 KB
testcase_19 AC 117 ms
53,260 KB
testcase_20 AC 50 ms
49,464 KB
testcase_21 AC 44 ms
49,480 KB
testcase_22 AC 44 ms
49,368 KB
testcase_23 AC 44 ms
49,496 KB
testcase_24 AC 48 ms
49,732 KB
testcase_25 AC 51 ms
49,372 KB
testcase_26 AC 44 ms
49,696 KB
testcase_27 AC 45 ms
49,568 KB
testcase_28 AC 44 ms
49,632 KB
testcase_29 AC 74 ms
51,648 KB
testcase_30 AC 63 ms
51,700 KB
testcase_31 AC 45 ms
49,484 KB
testcase_32 AC 43 ms
49,440 KB
testcase_33 AC 42 ms
49,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int max = Integer.parseInt(br.readLine());
        int N   = Integer.parseInt(br.readLine());
        String[] lines = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(String st:lines){
            list.add(Integer.parseInt(st));
        }
        Collections.sort(list);
        int ans = 0;
        for(int i:list){
            max -= i;
            if(max>=0){
                ans++;
            }else{
                break;
            }
        }
        System.out.println(ans);
    }
}
0