結果

問題 No.5 数字のブロック
ユーザー nanae
提出日時 2017-03-01 23:40:50
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 336 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 105,552 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 07:08:59
合計ジャッジ時間 1,724 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni;

void main(){
    auto L = readln.chomp.to!int;
    auto N = readln.chomp.to!int;
    auto W = readln.split.to!(int[]).sort();
    int cnt;

    foreach(w ; W){
        if(L - w < 0) break;
        L -= w;
        ++cnt;
    }

    writeln(cnt);
}
0