結果

問題 No.9 モンスターのレベル上げ
ユーザー codershifthcodershifth
提出日時 2015-07-12 17:58:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 439 ms / 5,000 ms
コード長 1,651 bytes
コンパイル時間 1,331 ms
コンパイル使用メモリ 154,536 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 03:54:41
合計ジャッジ時間 6,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 439 ms
4,376 KB
testcase_03 AC 349 ms
4,376 KB
testcase_04 AC 184 ms
4,376 KB
testcase_05 AC 121 ms
4,380 KB
testcase_06 AC 41 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 54 ms
4,380 KB
testcase_09 AC 419 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 377 ms
4,380 KB
testcase_12 AC 299 ms
4,376 KB
testcase_13 AC 201 ms
4,380 KB
testcase_14 AC 426 ms
4,380 KB
testcase_15 AC 388 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 250 ms
4,384 KB
testcase_18 AC 209 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;


class LevelUpMonster {
public:
    void solve(void) {
            int N;
            cin>>N;
            vector<int> A(N);
            vector<int> B(N);
            REP(i, N)
                cin>>A[i];
            REP(i, N)
                cin>>B[i];
            typedef pair<int,int> Status; // <(level),(battle count)>

            priority_queue<Status, vector<Status>, greater<Status>> que;
            int ans = (1<<30);

            // O(N^2*log(N))
            // 最初に戦う Monster ごとに試す
            REP(i, N)
            {
                REP(i, N)
                    que.emplace(A[i],0);
                REP(j, N)
                {
                    int level, count;
                    tie(level, count) = que.top();
                    que.pop();
                    que.emplace(level+B[(i+j)%N]/2, count+1);
                }
                int max_count = 0;
                while ( !que.empty() )
                {
                    int level, count;
                    tie(level, count) = que.top();
                    que.pop();
                    max_count = max(max_count, count);
                }
                ans = min(ans, max_count);
            }
            cout<<ans<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new LevelUpMonster();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0