結果

問題 No.9 モンスターのレベル上げ
ユーザー ei1333333
提出日時 2018-11-21 22:39:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 300 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 200,168 KB
最終ジャッジ日時 2025-01-06 17:05:33
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

using pi = pair< int, int >;

int main() {
  int N, A[1500], B[1500];
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }
  int ret = INF;
  for(int i = 0; i < N; i++) {
    priority_queue< pi, vector< pi >, greater<> > que;
    for(int j = 0; j < N; j++) que.emplace(A[j], 0);
    int res = 0;
    for(int j = 0; j < N; j++) {
      auto p = que.top();
      que.pop();
      res = max(res, p.second + 1);
      que.emplace(p.first + B[(i + j) % N] / 2, p.second + 1);
    }
    ret = min(ret, res);
  }
  cout << ret << endl;
}
0