結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,176 KB
testcase_01 AC 133 ms
41,212 KB
testcase_02 AC 136 ms
41,480 KB
testcase_03 AC 241 ms
46,372 KB
testcase_04 AC 227 ms
45,808 KB
testcase_05 AC 252 ms
47,220 KB
testcase_06 AC 228 ms
46,568 KB
testcase_07 AC 231 ms
45,496 KB
testcase_08 AC 242 ms
45,932 KB
testcase_09 AC 200 ms
43,240 KB
testcase_10 AC 260 ms
46,916 KB
testcase_11 AC 219 ms
45,832 KB
testcase_12 AC 244 ms
46,512 KB
testcase_13 AC 255 ms
47,060 KB
testcase_14 AC 146 ms
41,480 KB
testcase_15 AC 153 ms
41,884 KB
testcase_16 AC 261 ms
46,508 KB
testcase_17 AC 270 ms
47,520 KB
testcase_18 AC 269 ms
47,492 KB
testcase_19 AC 269 ms
47,288 KB
testcase_20 AC 118 ms
40,132 KB
testcase_21 AC 128 ms
41,348 KB
testcase_22 AC 128 ms
41,384 KB
testcase_23 AC 131 ms
41,248 KB
testcase_24 AC 152 ms
41,528 KB
testcase_25 AC 176 ms
41,908 KB
testcase_26 AC 127 ms
40,984 KB
testcase_27 AC 119 ms
40,064 KB
testcase_28 AC 115 ms
40,400 KB
testcase_29 AC 229 ms
45,660 KB
testcase_30 AC 204 ms
43,700 KB
testcase_31 AC 132 ms
41,280 KB
testcase_32 AC 135 ms
41,424 KB
testcase_33 AC 121 ms
39,952 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,i = 0;

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

        System.out.println(count);

    }
}
0