結果

問題 No.9 モンスターのレベル上げ
ユーザー togatogatogatoga
提出日時 2015-08-20 23:30:28
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 400 ms / 5,000 ms
コード長 1,166 bytes
コンパイル時間 1,259 ms
使用メモリ 5,156 KB
最終ジャッジ日時 2023-01-21 15:03:30
合計ジャッジ時間 5,649 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,900 KB
testcase_01 AC 1 ms
4,904 KB
testcase_02 AC 400 ms
5,156 KB
testcase_03 AC 319 ms
4,900 KB
testcase_04 AC 168 ms
4,904 KB
testcase_05 AC 110 ms
4,908 KB
testcase_06 AC 38 ms
4,904 KB
testcase_07 AC 2 ms
4,904 KB
testcase_08 AC 50 ms
4,904 KB
testcase_09 AC 391 ms
4,900 KB
testcase_10 AC 1 ms
4,900 KB
testcase_11 AC 322 ms
5,156 KB
testcase_12 AC 246 ms
4,904 KB
testcase_13 AC 190 ms
4,904 KB
testcase_14 AC 393 ms
4,904 KB
testcase_15 AC 356 ms
4,900 KB
testcase_16 AC 7 ms
4,904 KB
testcase_17 AC 227 ms
4,900 KB
testcase_18 AC 191 ms
4,904 KB
testcase_19 AC 5 ms
5,156 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