結果

問題 No.9 モンスターのレベル上げ
ユーザー tarakojo1019tarakojo1019
提出日時 2021-01-18 17:25:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 519 ms / 5,000 ms
コード長 1,511 bytes
コンパイル時間 1,358 ms
コンパイル使用メモリ 120,948 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 00:43:52
合計ジャッジ時間 6,695 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 519 ms
4,380 KB
testcase_03 AC 408 ms
4,376 KB
testcase_04 AC 217 ms
4,380 KB
testcase_05 AC 142 ms
4,380 KB
testcase_06 AC 49 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 65 ms
4,376 KB
testcase_09 AC 502 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 416 ms
4,376 KB
testcase_12 AC 334 ms
4,380 KB
testcase_13 AC 276 ms
4,380 KB
testcase_14 AC 503 ms
4,376 KB
testcase_15 AC 459 ms
4,380 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 295 ms
4,376 KB
testcase_18 AC 247 ms
4,376 KB
testcase_19 AC 5 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0