結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
koyopro
|
| 提出日時 | 2015-09-27 22:30:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 346 ms / 5,000 ms |
| コード長 | 2,201 bytes |
| コンパイル時間 | 768 ms |
| コンパイル使用メモリ | 85,696 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 23:06:11 |
| 合計ジャッジ時間 | 4,708 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <iostream>
#include <sstream>
#include <math.h>
#include <vector>
#include <array>
#include <algorithm>
#include <queue>
#include <numeric>
#include <map>
#include <set>
#include <bitset>
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define SUM(a) accumulate(ALL(a), 0)
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)
typedef pair<int, int> pos;
int pos::*x = &pos::first;
int pos::*y = &pos::second;
int dxy[] = {0, 1, 0, -1, 0};
/*================================*/
struct monster { int lv, battle; };
bool comp(monster& m1, monster& m2) {
if (m1.lv != m2.lv) return m1.lv > m2.lv;
return m1.battle > m2.battle;
}
class Compare
{
public:
bool operator() (monster& m1, monster& m2) {
if (m1.lv != m2.lv) return m1.lv > m2.lv;
return m1.battle > m2.battle;
}
};
int N;
vector<monster> A, B;
signed main()
{
cin >> N;
int lv;
REP(i,N) {
cin >> lv;
monster m = monster();
m.battle = 0;
m.lv = lv;
A.push_back(m);
}
REP(i,N) {
cin >> lv;
monster m = monster();
m.battle = 0;
m.lv = lv;
B.push_back(m);
}
int minmax = N;
REP(i,N) {
priority_queue<monster, vector<monster>, Compare> pq = priority_queue<monster, vector<monster>, Compare>();
REP(j,N) pq.push(A[j]);
REP(j,N) {
monster a = pq.top();
pq.pop();
a.lv += B[(i+j)%N].lv / 2;
a.battle++;
pq.push(a);
}
int maxbattle = 0;
while (pq.size()) {
maxbattle = max(maxbattle, pq.top().battle);
pq.pop();
}
minmax = min(minmax, maxbattle);
}
cout << minmax << endl;
return 0;
}
koyopro