結果

問題 No.5 数字のブロック
コンテスト
ユーザー SagToki
提出日時 2018-05-02 13:56:09
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 158 ms / 5,000 ms
+ 656µs
コード長 955 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,233 ms
コンパイル使用メモリ 85,712 KB
実行使用メモリ 49,076 KB
最終ジャッジ日時 2026-09-25 20:06:55
合計ジャッジ時間 7,475 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/*
 * 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