結果
問題 |
No.9 モンスターのレベル上げ
|
ユーザー |
|
提出日時 | 2017-01-13 17:15:33 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 297 ms / 5,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 773 ms |
コンパイル使用メモリ | 118,092 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 06:24:21 |
合計ジャッジ時間 | 4,099 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.container; // SList, DList, BinaryHeap import std.typecons; // Tuple, Nullable, BigFlags void main() { auto n = readln.chomp.to!size_t; auto ai = readln.split.to!(int[]); auto bi = readln.split.to!(int[]); auto hi = ai.map!(a => Monster(a, 0)).array.heapify!"a.lv != b.lv ? a.lv > b.lv : a.cnt > b.cnt"; auto r = n; foreach (i; n.iota) { auto ci = hi.dup; auto di = bi.cycle.drop(i).take(n); auto maxCnt = 0; foreach (d; di) { auto c = ci.front; ci.replaceFront(Monster(c.lv + d / 2, c.cnt + 1)); maxCnt = max(maxCnt, c.cnt + 1); } r = min(r, maxCnt); } writeln(r); } struct Monster { int lv; int cnt; }