結果

問題 No.5 数字のブロック
ユーザー kaoetayakaoetaya
提出日時 2016-12-09 17:16:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 262 ms / 5,000 ms
コード長 537 bytes
コンパイル時間 3,237 ms
コンパイル使用メモリ 74,976 KB
実行使用メモリ 47,824 KB
最終ジャッジ日時 2024-04-29 08:44:17
合計ジャッジ時間 10,337 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
40,164 KB
testcase_01 AC 115 ms
41,388 KB
testcase_02 AC 118 ms
41,556 KB
testcase_03 AC 223 ms
46,248 KB
testcase_04 AC 206 ms
45,980 KB
testcase_05 AC 255 ms
47,404 KB
testcase_06 AC 227 ms
46,180 KB
testcase_07 AC 222 ms
45,572 KB
testcase_08 AC 225 ms
47,188 KB
testcase_09 AC 193 ms
43,436 KB
testcase_10 AC 242 ms
47,052 KB
testcase_11 AC 218 ms
46,172 KB
testcase_12 AC 240 ms
46,592 KB
testcase_13 AC 249 ms
47,184 KB
testcase_14 AC 133 ms
41,296 KB
testcase_15 AC 150 ms
41,928 KB
testcase_16 AC 249 ms
46,968 KB
testcase_17 AC 261 ms
47,132 KB
testcase_18 AC 240 ms
47,820 KB
testcase_19 AC 262 ms
47,824 KB
testcase_20 AC 126 ms
41,128 KB
testcase_21 AC 121 ms
41,100 KB
testcase_22 AC 115 ms
41,380 KB
testcase_23 AC 112 ms
41,400 KB
testcase_24 AC 139 ms
41,368 KB
testcase_25 AC 147 ms
41,680 KB
testcase_26 AC 120 ms
40,272 KB
testcase_27 AC 115 ms
39,976 KB
testcase_28 AC 115 ms
40,356 KB
testcase_29 AC 215 ms
45,588 KB
testcase_30 AC 203 ms
43,948 KB
testcase_31 AC 115 ms
41,640 KB
testcase_32 AC 104 ms
41,432 KB
testcase_33 AC 124 ms
41,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Test {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int l = s.nextInt();
        int n = s.nextInt();
        int w[] = new int[n];

        for(int i=0;i<n;i++){
        	w[i] = s.nextInt();
        }

        Arrays.sort(w);

        int count = 0;

        for(int i=0;i<n;i++){
        	l -= w[i];
        	if(l >= 0){
        		count++;
        	}
        	else{
        		break;
        	}
        }

        System.out.println(count);

    }
}
0