結果

問題 No.9 モンスターのレベル上げ
ユーザー nebukuro09nebukuro09
提出日時 2016-11-02 17:17:59
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 920 ms / 5,000 ms
コード長 813 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 98,364 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2023-09-02 22:42:43
合計ジャッジ時間 9,731 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 920 ms
6,752 KB
testcase_03 AC 724 ms
6,820 KB
testcase_04 AC 385 ms
6,744 KB
testcase_05 AC 254 ms
6,788 KB
testcase_06 AC 89 ms
4,808 KB
testcase_07 AC 3 ms
4,368 KB
testcase_08 AC 119 ms
6,784 KB
testcase_09 AC 884 ms
6,720 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 770 ms
6,776 KB
testcase_12 AC 774 ms
6,780 KB
testcase_13 AC 579 ms
6,796 KB
testcase_14 AC 886 ms
6,756 KB
testcase_15 AC 809 ms
6,708 KB
testcase_16 AC 15 ms
4,368 KB
testcase_17 AC 522 ms
6,756 KB
testcase_18 AC 437 ms
6,772 KB
testcase_19 AC 9 ms
4,372 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