結果

問題 No.9 モンスターのレベル上げ
ユーザー togatogatogatoga
提出日時 2015-08-20 23:30:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 402 ms / 5,000 ms
コード長 1,166 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 153,172 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:14:35
合計ジャッジ時間 5,743 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 402 ms
4,380 KB
testcase_03 AC 320 ms
4,380 KB
testcase_04 AC 168 ms
4,376 KB
testcase_05 AC 109 ms
4,380 KB
testcase_06 AC 38 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 51 ms
4,380 KB
testcase_09 AC 392 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 323 ms
4,380 KB
testcase_12 AC 245 ms
4,376 KB
testcase_13 AC 190 ms
4,380 KB
testcase_14 AC 392 ms
4,376 KB
testcase_15 AC 355 ms
4,380 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 228 ms
4,376 KB
testcase_18 AC 192 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
priority_queue<pii> que;
vector<int> monster;
int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    que.push(mp(-x, 0));
  }
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    monster.push_back(x);
  }
  ll ans = INF;
  for (int start = 0; start < N; start++){
    priority_queue<pii> tmp = que;
    int cnt = 0;
    while (cnt < N){
      pii pos = tmp.top();
      tmp.pop();
      int level = monster[(start + cnt) % N] / 2;
      cnt++;
      pos.first -= level;
      pos.second--;
      tmp.push(pos);
    }
    ll res = 0;
    while (!tmp.empty()){
      pii pos = tmp.top();
      tmp.pop();
      res = max(res, (ll)-pos.second);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}
0