結果

問題 No.5 数字のブロック
ユーザー youthfuldays072youthfuldays072
提出日時 2018-05-20 11:23:41
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 561 bytes
コンパイル時間 2,099 ms
コンパイル使用メモリ 71,992 KB
実行使用メモリ 60,652 KB
最終ジャッジ日時 2023-09-10 23:56:12
合計ジャッジ時間 9,829 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,124 KB
testcase_01 AC 123 ms
55,992 KB
testcase_02 RE -
testcase_03 AC 227 ms
59,432 KB
testcase_04 AC 208 ms
59,404 KB
testcase_05 AC 242 ms
59,692 KB
testcase_06 AC 218 ms
59,868 KB
testcase_07 AC 209 ms
59,200 KB
testcase_08 AC 221 ms
59,800 KB
testcase_09 AC 195 ms
58,812 KB
testcase_10 AC 243 ms
60,632 KB
testcase_11 AC 213 ms
59,476 KB
testcase_12 AC 235 ms
59,940 KB
testcase_13 AC 238 ms
59,744 KB
testcase_14 AC 135 ms
55,744 KB
testcase_15 AC 159 ms
55,892 KB
testcase_16 AC 240 ms
60,284 KB
testcase_17 AC 251 ms
60,564 KB
testcase_18 AC 254 ms
60,592 KB
testcase_19 AC 255 ms
60,652 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 125 ms
56,392 KB
testcase_24 AC 150 ms
56,284 KB
testcase_25 AC 169 ms
56,000 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 209 ms
58,888 KB
testcase_30 AC 197 ms
58,220 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main {


    public static void main(String[] args) {

    	Scanner sc=new Scanner(System.in);

    	int L=sc.nextInt();
    	int N=sc.nextInt();

    	int[] w=new int[N];

    	for(int i=0;i<N;i++) {

    		w[i]=sc.nextInt();

    	}

    	Arrays.sort(w);

    	int index=0;
    	int counter=0;

    	while(true) {

    		if(L-w[index]>=0) {

    			L-=w[index++];
    			counter++;

    		}else {
    			break;
    		}

    	}

    	System.out.println(counter);

    	sc.close();

    }




}
0