結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2016-08-27 02:14:46 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 406 bytes |
| コンパイル時間 | 755 ms |
| コンパイル使用メモリ | 105,600 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-12 03:40:38 |
| 合計ジャッジ時間 | 1,816 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main()
{
auto l = readln.chomp.to!int;
auto n = readln.chomp.to!int;
auto wi = readln.split.map!(to!int).array;
wi.sort;
writeln(calc(l, wi));
}
int calc(int l, int[] wi)
{
auto a = 0;
foreach (i, w; wi) {
a += w;
if (a > l)
return i.to!int;
}
return wi.length.to!int;
}