結果

問題 No.9 モンスターのレベル上げ
ユーザー 👑 jupirojupiro
提出日時 2020-07-10 18:38:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 409 ms / 5,000 ms
コード長 1,792 bytes
コンパイル時間 1,230 ms
コンパイル使用メモリ 135,984 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-01 11:15:55
合計ジャッジ時間 5,840 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 409 ms
4,376 KB
testcase_03 AC 327 ms
4,376 KB
testcase_04 AC 167 ms
4,380 KB
testcase_05 AC 112 ms
4,376 KB
testcase_06 AC 37 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 49 ms
4,376 KB
testcase_09 AC 402 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 338 ms
4,376 KB
testcase_12 AC 259 ms
4,376 KB
testcase_13 AC 171 ms
4,376 KB
testcase_14 AC 396 ms
4,380 KB
testcase_15 AC 359 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 233 ms
4,376 KB
testcase_18 AC 195 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int n; scanf("%d", &n);
	vector<int> a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	vector<int> b(n); for (int i = 0; i < n; i++) scanf("%d", &b[i]);
	int res = inf;
	for (int s = 0; s < n; s++) {
		vector<int> c; c.reserve(n);
		for (int i = s; i < n; i++) c.emplace_back(b[i]);
		for (int i = 0; i < s; i++) c.emplace_back(b[i]);
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
		for (int i = 0; i < n; i++) pq.emplace(a[i], 0);
		for (int i = 0; i < n; i++) {
			auto p = pq.top();
			pq.pop();
			p.first += c[i] / 2;
			p.second += 1;
			pq.emplace(p);
		}
		int ans = 0;
		while (!pq.empty()) {
			chmax(ans, pq.top().second);
			pq.pop();
		}
		chmin(res, ans);
	}
	cout << res << endl;
	return 0;
}
0