結果

問題 No.5 数字のブロック
ユーザー presto
提出日時 2015-10-08 22:52:12
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 522 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 47,964 KB
最終ジャッジ日時 2024-07-20 02:16:19
合計ジャッジ時間 9,851 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

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];
        int sum = 0;
        for(int i = 0; i < n; i++) w[i] = sc.nextInt();
        Arrays.sort(w);
        for(int i = 0; i < n; i++){
           sum += w[i];
           if(sum > l){
             System.out.println(i);
             return;
           }
        }
    }
}
0