結果

問題 No.9 モンスターのレベル上げ
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-12-13 17:53:14
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 840 ms / 5,000 ms
コード長 1,129 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 117,844 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-09-02 23:27:34
合計ジャッジ時間 9,618 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,500 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 840 ms
6,752 KB
testcase_03 AC 652 ms
6,764 KB
testcase_04 AC 356 ms
6,788 KB
testcase_05 AC 234 ms
5,960 KB
testcase_06 AC 84 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 107 ms
5,448 KB
testcase_09 AC 811 ms
6,716 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 791 ms
6,764 KB
testcase_12 AC 800 ms
6,796 KB
testcase_13 AC 654 ms
6,760 KB
testcase_14 AC 840 ms
6,748 KB
testcase_15 AC 751 ms
6,796 KB
testcase_16 AC 14 ms
4,380 KB
testcase_17 AC 480 ms
6,784 KB
testcase_18 AC 396 ms
6,760 KB
testcase_19 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N = readln.chomp.to!int;
    auto A = readln.chomp.split(" ").map!(to!int).array;
    auto B = readln.chomp.split(" ").map!(to!int).array;

    int f(int s) {
        int next(int i) { return (i + 1) % N; }
        auto c = new int[N];
        BinaryHeap!(Array!(Tuple!(int, int)), delegate(a, b) { return a[0] == b[0] ? c[a[1]] > c[b[1]] : a > b; }) h;
        foreach (i; 0 .. N) {
            h.insert(tuple(A[i], i));
        }
        for (int i = s, flag = true; flag || i != s; i = next(i), flag = false) {
            auto x = h.front; h.removeFront;
            c[ x[1] ]++;
            h.insert(tuple(x[0] + B[i] / 2, x[1]));
        }
        return reduce!max(0, c);
    }

    int ans = int.max;
    for (int i = 0; i < N; i++) {
        ans = min(ans, f(i));
    }
    writeln(ans);
}
0