結果

問題 No.9 モンスターのレベル上げ
ユーザー かにかに
提出日時 2015-11-21 20:34:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 447 ms / 5,000 ms
コード長 1,846 bytes
コンパイル時間 1,317 ms
コンパイル使用メモリ 154,576 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:26:47
合計ジャッジ時間 6,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 447 ms
4,376 KB
testcase_03 AC 357 ms
4,376 KB
testcase_04 AC 186 ms
4,380 KB
testcase_05 AC 122 ms
4,380 KB
testcase_06 AC 42 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 55 ms
4,376 KB
testcase_09 AC 431 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 373 ms
4,376 KB
testcase_12 AC 291 ms
4,380 KB
testcase_13 AC 204 ms
4,376 KB
testcase_14 AC 429 ms
4,376 KB
testcase_15 AC 392 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 247 ms
4,380 KB
testcase_18 AC 207 ms
4,380 KB
testcase_19 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#define aLL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXISt(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define MAX 100000000
#define pb push_back
#define mp make_pair
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef pair<pair<int, int>, int> pp;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

int sttoi(std::string str) {
	int ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

bool sort_greater(const pair<string, int> &a, const pair<string, int> &b) {
	return a.second > b.second;
}
int gcd(int a, int b){
	if (b > a)swap(a, b);if (b == 0)return a;else{return gcd(b, a%b);}
}

void solve() {
	int n;
	cin >> n;
	vector<int> me;
	vector<int> enemy;
	rep(i, n){
		int a;
		cin >> a;
		me.push_back(a);
	}
	rep(i, n){
		int a;
		cin >> a;
		enemy.push_back(a);
	}
	int maxi = -1;
	int mini = 10000000;
	rep(i, enemy.size()){
		priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > copy;
		rep(j, me.size()){
			copy.push(make_pair(me[j], 0));
		}
		REP(j, i, enemy.size()){
			pair<int, int> p = copy.top();
			copy.pop();
			int e = enemy[j];
			copy.push(make_pair(p.first + (e / 2), p.second + 1));
		}
		REP(j, 0, i){
			pair<int, int> p = copy.top();
			copy.pop();
			int e = enemy[j];
			copy.push(make_pair(p.first + (e / 2), p.second + 1));
		}
		maxi = -1;
		while (!copy.empty()){
			pair<int, int> p = copy.top();
			copy.pop();
			maxi = max(maxi, p.second);
		}
		mini = min(mini, maxi);
	}
	P(mini);
}

int main() {
	solve();
	return 0;
}
0