結果

問題 No.5 数字のブロック
ユーザー ark723ark723
提出日時 2016-02-17 20:13:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 1,161 bytes
コンパイル時間 3,407 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 40,016 KB
最終ジャッジ日時 2024-04-29 06:57:18
合計ジャッジ時間 6,845 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,828 KB
testcase_01 AC 51 ms
36,916 KB
testcase_02 AC 52 ms
37,172 KB
testcase_03 AC 82 ms
38,436 KB
testcase_04 AC 71 ms
38,468 KB
testcase_05 AC 94 ms
39,252 KB
testcase_06 AC 87 ms
38,348 KB
testcase_07 AC 85 ms
38,476 KB
testcase_08 AC 93 ms
38,708 KB
testcase_09 AC 59 ms
37,028 KB
testcase_10 AC 90 ms
39,608 KB
testcase_11 AC 84 ms
38,360 KB
testcase_12 AC 99 ms
39,396 KB
testcase_13 AC 98 ms
39,196 KB
testcase_14 AC 51 ms
36,724 KB
testcase_15 AC 52 ms
36,684 KB
testcase_16 AC 94 ms
39,520 KB
testcase_17 AC 103 ms
40,016 KB
testcase_18 AC 105 ms
39,740 KB
testcase_19 AC 107 ms
39,792 KB
testcase_20 AC 51 ms
37,032 KB
testcase_21 AC 51 ms
36,916 KB
testcase_22 AC 51 ms
36,964 KB
testcase_23 AC 51 ms
37,036 KB
testcase_24 AC 51 ms
36,964 KB
testcase_25 AC 52 ms
36,796 KB
testcase_26 AC 50 ms
36,964 KB
testcase_27 AC 51 ms
37,164 KB
testcase_28 AC 51 ms
37,248 KB
testcase_29 AC 69 ms
38,380 KB
testcase_30 AC 59 ms
37,264 KB
testcase_31 AC 50 ms
37,084 KB
testcase_32 AC 51 ms
36,964 KB
testcase_33 AC 51 ms
36,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package yukicoder001_100;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author yuya
 */
public class No005 {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line1 = br.readLine();
        String line2 = br.readLine();
        String line3 = br.readLine();
        int L = Integer.parseInt(line1);
        int N = Integer.parseInt(line2);
        
        String [] s = line3.split(" ",0);
        int n[] = new int[N];
        
        for(int i=0;i<s.length;i++){
            n[i]=Integer.parseInt(s[i]);
        }
        Arrays.sort(n);
        int ans=0;
        int b =0;
        for(int i=0;i<=n.length-1;i++){
            b+=n[i];
            if(b<=L){
                
                ans++;
            }else{
                break;
            }
        }
        System.out.println(ans);
    }
}
0