結果

問題 No.9 モンスターのレベル上げ
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-12-13 17:49:36
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,069 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 115,984 KB
実行使用メモリ 6,928 KB
最終ジャッジ日時 2023-09-02 23:27:23
合計ジャッジ時間 10,210 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 897 ms
6,928 KB
testcase_03 WA -
testcase_04 AC 377 ms
6,736 KB
testcase_05 AC 251 ms
6,020 KB
testcase_06 AC 88 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 116 ms
5,144 KB
testcase_09 AC 873 ms
6,904 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 793 ms
6,868 KB
testcase_12 AC 811 ms
6,868 KB
testcase_13 WA -
testcase_14 AC 874 ms
6,912 KB
testcase_15 AC 799 ms
6,904 KB
testcase_16 AC 15 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 429 ms
6,852 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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; }
        BinaryHeap!(Array!(Tuple!(int, int)), "a > b") h;
        foreach (i; 0 .. N) {
            h.insert(tuple(A[i], i));
        }
        auto c = new int[N];
        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