結果

問題 No.9 モンスターのレベル上げ
ユーザー alpha_virginisalpha_virginis
提出日時 2016-08-15 22:16:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,503 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 169,056 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 07:43:09
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,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 2 ms
5,376 KB
testcase_11 AC 241 ms
5,376 KB
testcase_12 AC 241 ms
5,376 KB
testcase_13 AC 204 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

template<typename T> T in() { abort(); return T(); }
template<> std::string in() { std::string str; std::cin >> str; return str; }
template<> int in() { int x; scanf("%d", &x); return x; }

template<typename T> void out(T x) { abort(); }
template<> void out(const char* x) { printf("%s\n", x); }
template<> void out(std::string x) { std::cout << x << std::endl; }
template<> void out(int x) { printf("%d\n", x); }
template<> void out(long x) { printf("%ld\n", x); }

struct Monster {
  Monster() {}
  Monster(int level_, int times_) : level(level_), times(times_) {}
  int level;
  int times;  
};

bool operator < (const Monster& a, const Monster& b) {
  if( a.level != b.level ) {
    return a.level > b.level;
  }
  return a.times > b.times;
}

inline Monster battle(Monster monster, int lv) {
  return Monster(monster.level + lv / 2, monster.times + 1);
}

int n;
int xs[2048];
int ys[2048];

int main() {
  n = in<int>();
  for(int i = 0; i < n; ++i) xs[i] = in<int>();
  for(int i = 0; i < n; ++i) ys[i] = in<int>();

  int res = 0;
  for(int i = 0; i < n; ++i) {
    std::priority_queue<Monster> q;
    for(int j = 0; j < n; ++j) {
      q.push(Monster(xs[j], 0));
    }
    for(int j = 0; j < n; ++j) {
      int k = (i + j) % n;
      Monster monster = q.top(); q.pop();
      q.push(battle(monster, ys[k]));
    }
    while( not q.empty() ) {
      Monster monster = q.top(); q.pop();
      res = std::max(res, monster.times);
    }
  }

  out(res);
  
  return 0;
}
0