結果

問題 No.9 モンスターのレベル上げ
ユーザー koyoprokoyopro
提出日時 2015-09-27 22:30:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 374 ms / 5,000 ms
コード長 2,201 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 79,616 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:16:38
合計ジャッジ時間 4,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 374 ms
4,376 KB
testcase_03 AC 296 ms
4,380 KB
testcase_04 AC 150 ms
4,380 KB
testcase_05 AC 103 ms
4,380 KB
testcase_06 AC 35 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 44 ms
4,376 KB
testcase_09 AC 366 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 346 ms
4,376 KB
testcase_12 AC 350 ms
4,380 KB
testcase_13 AC 255 ms
4,380 KB
testcase_14 AC 367 ms
4,380 KB
testcase_15 AC 322 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 211 ms
4,376 KB
testcase_18 AC 169 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <math.h>
#include <vector>
#include <array>
#include <algorithm>
#include <queue>
#include <numeric>
#include <map>
#include <set>
#include <bitset>

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define SUM(a) accumulate(ALL(a), 0)
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

typedef pair<int, int> pos;
int pos::*x = &pos::first;
int pos::*y = &pos::second;

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

struct monster { int lv, battle; };

bool comp(monster& m1, monster& m2) {
    if (m1.lv != m2.lv) return m1.lv > m2.lv;
    return m1.battle > m2.battle;
}

class Compare
{
public:
    bool operator() (monster& m1, monster& m2) {
        if (m1.lv != m2.lv) return m1.lv > m2.lv;
        return m1.battle > m2.battle;
    }
};


int N;
vector<monster> A, B;

signed main()
{
    cin >> N;
    int lv;
    REP(i,N) {
        cin >> lv;
        monster m = monster();
        m.battle = 0;
        m.lv = lv;
        A.push_back(m);
    }
    REP(i,N) {
        cin >> lv;
        monster m = monster();
        m.battle = 0;
        m.lv = lv;
        B.push_back(m);
    }
    
    int minmax = N;
    
    REP(i,N) {
        priority_queue<monster, vector<monster>, Compare> pq = priority_queue<monster, vector<monster>, Compare>();
        REP(j,N) pq.push(A[j]);
        REP(j,N) {
            monster a = pq.top();
            pq.pop();
            a.lv += B[(i+j)%N].lv / 2;
            a.battle++;
            pq.push(a);
        }
        int maxbattle = 0;
        while (pq.size()) {
            maxbattle = max(maxbattle, pq.top().battle);
            pq.pop();
        }
        minmax = min(minmax, maxbattle);
    }
    
    cout << minmax << endl;
    
    
    return 0;
}
0