結果

問題 No.9 モンスターのレベル上げ
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-06-18 14:42:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 447 ms / 5,000 ms
コード長 1,077 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 74,776 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 05:28:41
合計ジャッジ時間 5,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 447 ms
4,380 KB
testcase_03 AC 359 ms
4,376 KB
testcase_04 AC 188 ms
4,376 KB
testcase_05 AC 123 ms
4,376 KB
testcase_06 AC 42 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 56 ms
4,376 KB
testcase_09 AC 441 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 381 ms
4,380 KB
testcase_12 AC 296 ms
4,376 KB
testcase_13 AC 201 ms
4,376 KB
testcase_14 AC 443 ms
4,380 KB
testcase_15 AC 400 ms
4,376 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 256 ms
4,380 KB
testcase_18 AC 216 ms
4,380 KB
testcase_19 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
using namespace std;

constexpr int inf = 987654321;

int main(void) {
  int n; scanf("%d", &n);
  vector<int> a(n, 0); // a[n]
  vector<int> b(n, 0); // b[n]
  for(int i=0; i<n; ++i) { scanf("%d", &a[i]); }
  for(int i=0; i<n; ++i) { scanf("%d", &b[i]); }
  int res = inf;
  for(int i=0; i<n; ++i) { // 敵の最初を決める
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    for(int j=0; j<n; ++j) {
      // 味方: レベル、戦闘回数
      pq.emplace(a[j], 0);
    }
    int mini = inf;
    for(int kk=i; kk<i+n; ++kk) {
      int k = kk % n; // 敵の番号
      int level, cnt; tie(level, cnt) = pq.top(); pq.pop(); // 対戦する味方の情報
      pq.emplace(level + b[k] / 2, cnt+1);
    }
    int maxi = 0; // 戦闘回数が最大な味方の、その回数
    while(!pq.empty()) {
      int _, cnt; tie(_, cnt) = pq.top(); pq.pop();
      maxi = max(maxi, cnt);
    }
    res = min(res, maxi);
  }
  printf("%d\n", res);
  return 0;
}
0