結果

問題 No.5 数字のブロック
ユーザー youthfuldays072youthfuldays072
提出日時 2018-05-20 11:25:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 72,332 KB
実行使用メモリ 61,276 KB
最終ジャッジ日時 2023-09-10 23:56:25
合計ジャッジ時間 9,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
54,444 KB
testcase_01 AC 123 ms
55,808 KB
testcase_02 WA -
testcase_03 AC 227 ms
59,472 KB
testcase_04 AC 214 ms
59,224 KB
testcase_05 AC 240 ms
60,044 KB
testcase_06 AC 220 ms
59,064 KB
testcase_07 AC 215 ms
61,276 KB
testcase_08 AC 228 ms
59,384 KB
testcase_09 AC 192 ms
58,252 KB
testcase_10 AC 248 ms
60,248 KB
testcase_11 AC 215 ms
57,760 KB
testcase_12 AC 233 ms
59,740 KB
testcase_13 AC 241 ms
60,312 KB
testcase_14 AC 134 ms
55,632 KB
testcase_15 AC 158 ms
56,108 KB
testcase_16 AC 242 ms
59,628 KB
testcase_17 AC 251 ms
60,640 KB
testcase_18 AC 249 ms
60,032 KB
testcase_19 AC 266 ms
61,036 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 121 ms
55,784 KB
testcase_24 AC 148 ms
56,128 KB
testcase_25 AC 177 ms
55,732 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 209 ms
59,060 KB
testcase_30 AC 193 ms
57,172 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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 && index+1<=N-1) {

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

    		}else {
    			break;
    		}

    	}

    	System.out.println(counter);

    	sc.close();

    }




}
0