結果

問題 No.9 モンスターのレベル上げ
ユーザー daleksprinterdaleksprinter
提出日時 2018-09-23 09:26:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 543 ms / 5,000 ms
コード長 2,197 bytes
コンパイル時間 2,390 ms
コンパイル使用メモリ 176,464 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-11 14:52:16
合計ジャッジ時間 7,754 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 543 ms
4,352 KB
testcase_03 AC 429 ms
4,356 KB
testcase_04 AC 228 ms
4,352 KB
testcase_05 AC 149 ms
4,352 KB
testcase_06 AC 50 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 67 ms
4,348 KB
testcase_09 AC 529 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 458 ms
4,368 KB
testcase_12 AC 371 ms
4,352 KB
testcase_13 AC 294 ms
4,352 KB
testcase_14 AC 530 ms
4,348 KB
testcase_15 AC 487 ms
4,356 KB
testcase_16 AC 9 ms
4,352 KB
testcase_17 AC 309 ms
4,348 KB
testcase_18 AC 258 ms
4,356 KB
testcase_19 AC 5 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100000;
const int mod = 1000000007;

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}

//main_method-----------------------------------------------------------------------------------
auto c = [](pair<int, int> l, pair<int,int> r) { if(l.second != r.second) return l.second > r.second; else return l.first > r.first;};

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n = input();
    vector<int> levels; rep(i,0,n) levels.push_back(input());
    vector<int> monsters; rep(i,0,n) monsters.push_back(input());

    int ans = inf;
    rep(i,0,n){
        priority_queue<pair<int, int>,vector<pair<int, int>>, decltype(c) > q(c);
        rep(i,0,n) q.push(make_pair(0, levels[i]));
        rep(j,0,n){
            pair<int, int> t = q.top(); q.pop();
            t.first += 1; t.second += monsters[(i+j)%n]/2;
            q.push(t);
        }

        int cnt = 0;
        while(not q.empty()){
            cnt = max(cnt, q.top().first);
            q.pop();
        }
        ans = min(ans, cnt);

    }
    print(ans);



}
0