結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2021-01-18 17:25:22 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 370 ms / 5,000 ms |
コード長 | 1,511 bytes |
コンパイル時間 | 980 ms |
使用メモリ | 3,632 KB |
最終ジャッジ日時 | 2023-01-07 08:43:34 |
合計ジャッジ時間 | 5,676 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge16 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,500 KB |
testcase_01 | AC | 1 ms
3,552 KB |
testcase_02 | AC | 370 ms
3,560 KB |
testcase_03 | AC | 294 ms
3,456 KB |
testcase_04 | AC | 152 ms
3,424 KB |
testcase_05 | AC | 102 ms
3,580 KB |
testcase_06 | AC | 35 ms
3,492 KB |
testcase_07 | AC | 2 ms
3,384 KB |
testcase_08 | AC | 46 ms
3,556 KB |
testcase_09 | AC | 361 ms
3,600 KB |
testcase_10 | AC | 1 ms
3,500 KB |
testcase_11 | AC | 329 ms
3,628 KB |
testcase_12 | AC | 343 ms
3,612 KB |
testcase_13 | AC | 255 ms
3,452 KB |
testcase_14 | AC | 365 ms
3,632 KB |
testcase_15 | AC | 329 ms
3,608 KB |
testcase_16 | AC | 7 ms
3,508 KB |
testcase_17 | AC | 210 ms
3,508 KB |
testcase_18 | AC | 173 ms
3,516 KB |
testcase_19 | AC | 4 ms
3,532 KB |
ソースコード
#include<iostream> #include<math.h> #include<algorithm> #include<stdint.h> #include<vector> #include<deque> #include<stack> #include<functional> #include<string> #include<numeric> #include<cstring> #include<random> #include<array> #include<fstream> #include<iomanip> #include<list> #include<set> #include<map> #include<unordered_map> #include<unordered_set> #include<bitset> #include<queue> /* #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; */ using namespace std; using ll = long long; using ull = unsigned long long; #define REP(i,a,b) for(ll i = a; i < b; ++i) #define PRI(s) std::cout << s << endl #define PRIF(v, n) printf("%."#n"f\n", (double)v) template<typename A, typename B>void mins(A& a, const B& b) { a = min(a, (A)b); }; template<typename A, typename B>void maxs(A& a, const B& b) { a = max(a, (A)b); }; int main() { ll N; cin >> N; vector<ll> A(N); REP(i, 0, N) cin >> A[i]; vector<ll> B(N); REP(i, 0, N) cin >> B[i]; ll ans = 1e18; REP(s, 0, N) { auto cmp = [](auto a, auto b) { if (a.first == b.first) return a.second > b.second; return a.first > b.first; }; priority_queue<pair<ll, ll>, vector< pair<ll, ll>>, decltype(cmp)> q{ cmp }; REP(i, 0, N) q.push({ A[i], 0 }); REP(i, 0, N) { ll ind = (i + s) % N; auto p = q.top(); q.pop(); p.first += B[ind] / 2; p.second++; q.push(p); } ll tmp = 0; while (!q.empty()) maxs(tmp, q.top().second), q.pop(); mins(ans, tmp); } PRI(ans); return 0; }