結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | te-sh |
提出日時 | 2016-09-01 00:31:49 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 998 ms / 5,000 ms |
コード長 | 966 bytes |
コンパイル時間 | 954 ms |
コンパイル使用メモリ | 115,948 KB |
実行使用メモリ | 6,732 KB |
最終ジャッジ日時 | 2023-09-02 21:48:36 |
合計ジャッジ時間 | 10,290 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,368 KB |
testcase_01 | AC | 1 ms
4,372 KB |
testcase_02 | AC | 998 ms
6,648 KB |
testcase_03 | AC | 777 ms
6,708 KB |
testcase_04 | AC | 414 ms
6,656 KB |
testcase_05 | AC | 274 ms
6,648 KB |
testcase_06 | AC | 95 ms
6,648 KB |
testcase_07 | AC | 3 ms
4,368 KB |
testcase_08 | AC | 126 ms
6,668 KB |
testcase_09 | AC | 968 ms
6,720 KB |
testcase_10 | AC | 2 ms
4,372 KB |
testcase_11 | AC | 734 ms
6,700 KB |
testcase_12 | AC | 533 ms
6,720 KB |
testcase_13 | AC | 357 ms
6,680 KB |
testcase_14 | AC | 966 ms
6,712 KB |
testcase_15 | AC | 883 ms
6,732 KB |
testcase_16 | AC | 16 ms
5,388 KB |
testcase_17 | AC | 564 ms
6,684 KB |
testcase_18 | AC | 474 ms
6,672 KB |
testcase_19 | AC | 10 ms
4,372 KB |
ソースコード
import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random; import std.string, std.conv, std.stdio, std.typecons; struct monster { long level; long count; int opCmp(monster rhs) { int sign(long n) { return n == 0 ? 0 : (n > 0 ? 1 : -1); } auto s1 = sign(level - rhs.level); auto s2 = sign(count - rhs.count); return s1 == 0 ? s2 : s1; } } void main() { auto n = readln.chomp.to!int; auto ai = readln.split.map!(to!long).array; auto bi = readln.split.map!(to!long).array; auto r = iota(n).map!(i => bi[i..$] ~ bi[0..i]).map!(bi => calcCount(ai, bi)).reduce!(min); writeln(r); } long calcCount(long[] ai, long[] bi) { auto mi = ai.map!(a => monster(a, 0)).array; auto hi = mi.heapify!("a > b"); foreach (b; bi) { auto h = hi.front; hi.replaceFront(monster(h.level + b / 2, h.count + 1)); } return hi.map!("a.count").reduce!(max); }