結果

問題 No.5 数字のブロック
ユーザー SagTokiSagToki
提出日時 2018-05-02 13:56:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 288 ms / 5,000 ms
コード長 955 bytes
コンパイル時間 3,762 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 47,488 KB
最終ジャッジ日時 2024-04-29 09:48:29
合計ジャッジ時間 11,554 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
41,304 KB
testcase_01 AC 146 ms
41,324 KB
testcase_02 AC 143 ms
41,308 KB
testcase_03 AC 267 ms
46,240 KB
testcase_04 AC 245 ms
45,728 KB
testcase_05 AC 288 ms
46,404 KB
testcase_06 AC 266 ms
46,060 KB
testcase_07 AC 231 ms
45,872 KB
testcase_08 AC 268 ms
46,096 KB
testcase_09 AC 220 ms
43,712 KB
testcase_10 AC 270 ms
46,604 KB
testcase_11 AC 223 ms
45,760 KB
testcase_12 AC 243 ms
46,576 KB
testcase_13 AC 254 ms
46,360 KB
testcase_14 AC 141 ms
41,564 KB
testcase_15 AC 163 ms
41,540 KB
testcase_16 AC 260 ms
47,180 KB
testcase_17 AC 274 ms
47,488 KB
testcase_18 AC 273 ms
47,120 KB
testcase_19 AC 274 ms
47,372 KB
testcase_20 AC 131 ms
41,360 KB
testcase_21 AC 129 ms
41,156 KB
testcase_22 AC 131 ms
41,416 KB
testcase_23 AC 131 ms
41,264 KB
testcase_24 AC 158 ms
41,832 KB
testcase_25 AC 175 ms
42,240 KB
testcase_26 AC 133 ms
41,384 KB
testcase_27 AC 116 ms
40,148 KB
testcase_28 AC 130 ms
41,260 KB
testcase_29 AC 223 ms
45,992 KB
testcase_30 AC 204 ms
43,648 KB
testcase_31 AC 114 ms
40,200 KB
testcase_32 AC 133 ms
41,408 KB
testcase_33 AC 129 ms
41,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
/**
 *
 * @author tokio
 */
public class suuzi {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int L = scanner.nextInt();
        int N = scanner.nextInt();
        int[] W = new int[N];
        int sum = 0;
        int count = 0;
        
        for(int i=0 ; i<N ; i++){
            W[i] = scanner.nextInt();
        }
       
        Arrays.sort(W);
        
       
        //while(L >= sum){
           // sum += W[i];
           // i++;
       // }
       for(int i = 0 ; i < N ; i++){
           if(L >= sum + W[i]){
             sum += W[i];
               count++;
           }else{
               break;
           }
       }
    
        System.out.println(count);
        
    }
}
0