結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-01-11 14:45:13 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 355 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 106,240 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 06:18:09 |
合計ジャッジ時間 | 1,903 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto l = readln.chomp.to!int; auto n = readln.chomp.to!size_t; auto wi = readln.split.to!(int[]); wi.sort(); writeln(calc(l, wi)); } auto calc(int l, int[] wi) { int a = 0; foreach (i, w; wi) { a += w; if (a > l) return i; } return wi.length; }