結果

問題 No.9 モンスターのレベル上げ
ユーザー imulanimulan
提出日時 2016-06-20 14:15:03
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 509 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 1,496 ms
使用メモリ 3,660 KB
最終ジャッジ日時 2023-01-21 15:45:15
合計ジャッジ時間 6,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,596 KB
testcase_01 AC 1 ms
3,512 KB
testcase_02 AC 509 ms
3,612 KB
testcase_03 AC 404 ms
3,480 KB
testcase_04 AC 213 ms
3,592 KB
testcase_05 AC 139 ms
3,612 KB
testcase_06 AC 47 ms
3,516 KB
testcase_07 AC 2 ms
3,520 KB
testcase_08 AC 62 ms
3,532 KB
testcase_09 AC 494 ms
3,548 KB
testcase_10 AC 1 ms
3,512 KB
testcase_11 AC 428 ms
3,660 KB
testcase_12 AC 324 ms
3,544 KB
testcase_13 AC 219 ms
3,476 KB
testcase_14 AC 495 ms
3,600 KB
testcase_15 AC 449 ms
3,548 KB
testcase_16 AC 8 ms
3,508 KB
testcase_17 AC 289 ms
3,600 KB
testcase_18 AC 242 ms
3,624 KB
testcase_19 AC 5 ms
3,508 KB
権限があれば一括ダウンロードができます

ソースコード

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