結果

問題 No.9 モンスターのレベル上げ
ユーザー imulan
提出日時 2016-06-20 14:15:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 434 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 1,801 ms
コンパイル使用メモリ 173,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 23:31:23
合計ジャッジ時間 6,441 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int main()
{
    int n;
    cin >>n;
    vector<int> a(n),b(n);
    rep(i,n) scanf(" %d", &a[i]);
    rep(i,n) scanf(" %d", &b[i]);

    int ans=n;

    //スタート位置
    rep(i,n)
    {
        priority_queue<pi,vector<pi>,greater<pi>> que;

        //(レベル,戦闘回数)
        rep(j,n) que.push(pi(a[j],0));

        //バトルしていく
        rep(j,n)
        {
            pi m=que.top();
            que.pop();

            m.fi+=b[(i+j)%n]/2;
            ++m.se;

            que.push(m);
        }

        //最大の戦闘回数
        int t=0;
        while(!que.empty())
        {
            pi now=que.top();
            que.pop();
            t=max(t,now.se);
        }

        //最小値更新
        ans=min(ans,t);
    }



    cout << ans << endl;
    return 0;
}
0