結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2016-09-01 00:31:49 |
言語 | D (dmd 2.099.1) |
結果 |
AC
|
実行時間 | 998 ms / 5,000 ms |
コード長 | 966 bytes |
コンパイル時間 | 923 ms |
使用メモリ | 7,176 KB |
最終ジャッジ日時 | 2023-01-29 22:05:22 |
合計ジャッジ時間 | 10,456 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,352 KB |
testcase_01 | AC | 1 ms
3,332 KB |
testcase_02 | AC | 998 ms
7,144 KB |
testcase_03 | AC | 772 ms
7,044 KB |
testcase_04 | AC | 412 ms
7,160 KB |
testcase_05 | AC | 273 ms
7,164 KB |
testcase_06 | AC | 95 ms
7,160 KB |
testcase_07 | AC | 3 ms
3,332 KB |
testcase_08 | AC | 127 ms
7,176 KB |
testcase_09 | AC | 963 ms
7,060 KB |
testcase_10 | AC | 2 ms
3,304 KB |
testcase_11 | AC | 760 ms
7,024 KB |
testcase_12 | AC | 614 ms
7,124 KB |
testcase_13 | AC | 411 ms
7,176 KB |
testcase_14 | AC | 965 ms
7,160 KB |
testcase_15 | AC | 883 ms
7,132 KB |
testcase_16 | AC | 16 ms
4,328 KB |
testcase_17 | AC | 567 ms
7,144 KB |
testcase_18 | AC | 474 ms
7,152 KB |
testcase_19 | AC | 10 ms
4,028 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); }