結果

問題 No.9 モンスターのレベル上げ
ユーザー pyranine
提出日時 2020-12-23 19:52:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 271 ms / 5,000 ms
コード長 1,726 bytes
コンパイル時間 1,849 ms
コンパイル使用メモリ 177,432 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-21 16:29:51
合計ジャッジ時間 5,049 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using Int32 = int_fast32_t;
using Word32 = uint_fast32_t;
using Int64 = int_fast64_t;
using Word64 = uint_fast64_t;
using Int128 = __int128_t;
using Word128 = __uint128_t;
using Int = int_fast64_t;
using Word = uint_fast64_t;
using VInt = vector<Int>;
using VVI = vector<VInt>;
using VWord = vector<Word>;
using VVW = vector<VWord>;
using VS = vector<string>;
using VVS = vector<VS>;
using VB = vector<bool>;
using VVB = vector<VB>;
using PII = pair<Int,Int>;
using PWW = pair<Word,Word>;
using VPII = vector<PII>;
using VPWW = vector<PWW>;

#define SZ(x) ((Int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i,n) for(Int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i,n) for(Int i=0, i##_len=(n); i<=i##_len; ++i)
#define Range(i,a,b) for(Int i=(a); i<=(Int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define mp make_pair

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  Int n;
  cin >> n;

  priority_queue<PII, VPII, greater<PII>> pq;

  rep(i,n) {
    Int tmp;
    cin >> tmp;
    pq.push(mp(tmp, 0));
  }
  VInt enemy = VInt(n);
  rep(i,n) cin >> enemy[i];
  priority_queue<PII, VPII, greater<PII>> copy_pq = pq;
  Int result_min = n + 1;
  rep(d,n) {
    Int max_battle = 0;
    pq = copy_pq;
    rep(i,n) {
      Int index = (i + d) % n;
      PII mons = pq.top(); pq.pop();
      mons.first += enemy[index] / 2;
      mons.second++;
      pq.push(mons);
      if (mons.second > max_battle) max_battle = mons.second;
    }
    if(max_battle < result_min) result_min = max_battle;
  }
  cout << result_min << endl;
  return 0;
}
0