結果

問題 No.5 数字のブロック
ユーザー NaruYNaruY
提出日時 2016-12-09 16:14:13
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 701 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 75,712 KB
実行使用メモリ 47,540 KB
最終ジャッジ日時 2024-05-06 10:22:11
合計ジャッジ時間 9,670 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,184 KB
testcase_01 AC 133 ms
41,048 KB
testcase_02 RE -
testcase_03 AC 244 ms
46,596 KB
testcase_04 AC 226 ms
45,688 KB
testcase_05 AC 260 ms
47,248 KB
testcase_06 AC 237 ms
46,412 KB
testcase_07 AC 229 ms
45,428 KB
testcase_08 AC 248 ms
46,552 KB
testcase_09 AC 202 ms
43,224 KB
testcase_10 AC 260 ms
47,336 KB
testcase_11 AC 216 ms
46,172 KB
testcase_12 AC 249 ms
46,576 KB
testcase_13 AC 261 ms
46,844 KB
testcase_14 AC 134 ms
40,896 KB
testcase_15 AC 156 ms
41,380 KB
testcase_16 AC 251 ms
47,068 KB
testcase_17 AC 266 ms
47,408 KB
testcase_18 AC 270 ms
47,420 KB
testcase_19 AC 269 ms
47,540 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 132 ms
41,204 KB
testcase_24 AC 149 ms
41,552 KB
testcase_25 AC 172 ms
42,068 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 223 ms
45,652 KB
testcase_30 AC 199 ms
43,484 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	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-1 ; i++){
    		W[i] = sc.nextInt();
    	}
    	
    	Arrays.sort(W);
    	
    	int sum = 0;
    	int ans = 0;
    	for (int j = 0; sum + W[j] <= L ; j++){
    		ans = ans + 1;
    		sum = sum + W[j];
    	}
    	
    	System.out.println(ans);
    }
}
    
0