結果

問題 No.9 モンスターのレベル上げ
ユーザー simansiman
提出日時 2021-05-26 19:15:31
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,224 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 140,408 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 14:31:22
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 333 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 29 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 43 ms
5,376 KB
testcase_09 AC 320 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 126 ms
5,376 KB
testcase_14 AC 311 ms
5,376 KB
testcase_15 AC 290 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 192 ms
5,376 KB
testcase_18 AC 158 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Monster {
  int power;
  int cnt;

  Monster(int power = -1, int cnt = -1) {
    this->power = power;
    this->cnt = cnt;
  }

  bool operator>(const Monster &n) const {
    return power > n.power;
  }
};

int main() {
  int N;
  cin >> N;
  int A[N];
  int B[N];

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }

  int ans = INT_MAX;
  for (int i = 0; i < N; ++i) {
    priority_queue <Monster, vector<Monster>, greater<Monster>> pque;

    for (int j = 0; j < N; ++j) {
      pque.push(Monster(B[j], 0));
    }

    for (int j = 0; j < N; ++j) {
      int id = (j + i) % N;
      Monster m = pque.top();
      pque.pop();
      m.cnt++;
      m.power += A[id] / 2;
      pque.push(m);
    }

    int max_cnt = 0;

    while (not pque.empty()) {
      Monster m = pque.top();
      pque.pop();
      max_cnt = max(max_cnt, m.cnt);
    }

    ans = min(ans, max_cnt);
  }

  cout << ans << endl;

  return 0;
}
0