結果

問題 No.9 モンスターのレベル上げ
ユーザー nebukuro09nebukuro09
提出日時 2016-11-02 17:17:59
言語 D
(dmd 2.099.1)
結果
AC  
実行時間 1,065 ms / 5,000 ms
コード長 813 bytes
コンパイル時間 896 ms
使用メモリ 7,352 KB
最終ジャッジ日時 2023-01-30 01:34:41
合計ジャッジ時間 11,527 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,900 KB
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 1,065 ms
7,312 KB
testcase_03 AC 838 ms
7,188 KB
testcase_04 AC 446 ms
7,236 KB
testcase_05 AC 297 ms
7,228 KB
testcase_06 AC 104 ms
6,964 KB
testcase_07 AC 3 ms
4,908 KB
testcase_08 AC 138 ms
7,268 KB
testcase_09 AC 1,033 ms
7,260 KB
testcase_10 AC 1 ms
6,952 KB
testcase_11 AC 917 ms
7,244 KB
testcase_12 AC 905 ms
7,344 KB
testcase_13 AC 691 ms
7,284 KB
testcase_14 AC 1,030 ms
7,352 KB
testcase_15 AC 944 ms
7,260 KB
testcase_16 AC 17 ms
4,904 KB
testcase_17 AC 606 ms
7,196 KB
testcase_18 AC 510 ms
7,304 KB
testcase_19 AC 10 ms
4,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.container;

void main() {
  int N = readln().chomp.to!int;
  //auto C = readln().split.map!(to!int).array.heapify!"a > b";
  auto C = readln().split.map!(to!int);
  
  auto B = readln().split.map!(to!int).array;

  int ans = int.max;
  foreach (i; iota(N)) {
    int m = 0;
    Tuple!(int, int)[] D = new Tuple!(int, int)[](N);
    foreach (k; iota(N))
      D[k] = tuple(C[k], 0);
    auto A = D.heapify!"a > b";
    foreach (j; iota(N)) {
      Tuple!(int, int) top = A.front;
      A.removeFront;
      A.insert(tuple(top[0]+B[(i+j)%N]/2, top[1]+1));
    }
    foreach(a; A.take(N))
      if (a[1] > m)
        m = a[1];
    ans = min(ans, m);
  }

  writeln(ans);
}
0