結果

問題 No.9 モンスターのレベル上げ
ユーザー simansiman
提出日時 2021-05-26 19:40:18
言語 C++17(clang Beta)
(clang 13.0.0 + boost 1.78.0)
結果
AC  
実行時間 534 ms / 5,000 ms
コード長 1,300 bytes
コンパイル時間 810 ms
使用メモリ 3,460 KB
最終ジャッジ日時 2022-12-11 18:36:50
合計ジャッジ時間 6,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,380 KB
testcase_01 AC 1 ms
3,308 KB
testcase_02 AC 534 ms
3,452 KB
testcase_03 AC 420 ms
3,460 KB
testcase_04 AC 221 ms
3,348 KB
testcase_05 AC 145 ms
3,324 KB
testcase_06 AC 51 ms
3,396 KB
testcase_07 AC 3 ms
3,416 KB
testcase_08 AC 68 ms
3,420 KB
testcase_09 AC 522 ms
3,380 KB
testcase_10 AC 2 ms
3,288 KB
testcase_11 AC 473 ms
3,436 KB
testcase_12 AC 361 ms
3,432 KB
testcase_13 AC 262 ms
3,460 KB
testcase_14 AC 523 ms
3,456 KB
testcase_15 AC 474 ms
3,452 KB
testcase_16 AC 9 ms
3,416 KB
testcase_17 AC 305 ms
3,440 KB
testcase_18 AC 255 ms
3,348 KB
testcase_19 AC 5 ms
3,412 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 {
  ll level;
  int cnt;

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

  bool operator>(const Monster &n) const {
    return 1000000 * level + cnt > 1000000 * n.level + n.cnt;
  }
};

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 min_battle_cnt = 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(A[j], 0));
    }

    for (int j = 0; j < N; ++j) {
      int id = (j + i) % N;
      Monster m = pque.top();
      pque.pop();
      m.cnt++;
      m.level += B[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);
    }

    min_battle_cnt = min(min_battle_cnt, max_cnt);
  }

  cout << min_battle_cnt << endl;

  return 0;
}
0