結果

問題 No.9 モンスターのレベル上げ
コンテスト
ユーザー not_522
提出日時 2015-08-04 14:11:05
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 419 ms / 5,000 ms
コード長 746 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,481 ms
コンパイル使用メモリ 190,592 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-09 06:17:16
合計ジャッジ時間 5,340 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int& i : a) cin >> i;
  for (int& i : b) cin >> i;
  int res = numeric_limits<int>::max();
  for (int i = 0; i < n; ++i) {
    priority_queue<tuple<int, int>, vector<tuple<int, int>>, greater<tuple<int, int>>> que;
    for (int i = 0; i < n; ++i) que.push(make_tuple(a[i], 0));
    for (int i = 0; i < n; ++i) {
      auto p = que.top();
      que.pop();
      que.push(make_tuple(get<0>(p) + b[i] / 2, get<1>(p) + 1));
    }
    int mx = 0;
    while (!que.empty()) {
      mx = max(mx, get<1>(que.top()));
      que.pop();
    }
    res = min(res, mx);
    rotate(b.begin(), b.begin() + 1, b.end());
  }
  cout << res << endl;
}
0