結果

問題 No.9 モンスターのレベル上げ
ユーザー te-shte-sh
提出日時 2016-09-01 00:22:48
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 958 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 115,028 KB
実行使用メモリ 6,744 KB
最終ジャッジ日時 2023-09-02 21:48:24
合計ジャッジ時間 10,546 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,372 KB
testcase_11 AC 775 ms
6,720 KB
testcase_12 AC 499 ms
6,744 KB
testcase_13 AC 340 ms
6,656 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 {
  int level;
  int count;

  int opCmp(monster rhs) {
    int sign(int 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!int).array;
  auto bi = readln.split.map!(to!int).array;

  auto r = iota(n).map!(i => bi[i..$] ~ bi[0..i]).map!(bi => calcCount(ai, bi)).reduce!(max);
  writeln(r);
}

int calcCount(int[] ai, int[] 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);
}
0