結果
| 問題 |
No.9 モンスターのレベル上げ
|
| ユーザー |
|
| 提出日時 | 2014-10-05 15:59:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 378 ms / 5,000 ms |
| コード長 | 1,542 bytes |
| コンパイル時間 | 756 ms |
| コンパイル使用メモリ | 73,588 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 21:57:46 |
| 合計ジャッジ時間 | 4,606 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define mp make_pair
int N, A[1501], B[1501];
int solve(){
priority_queue<pair<int,int> > q0;
REP(i,N) q0.push(mp(-A[i],0));
int minv = 1<<29;
REP(i,N){
auto q = q0;
REP(j,N){
int add = B[(i+j)%N]/2;
auto a = q.top(); q.pop();
a.first-=add; a.second--;
q.push(a);
}
int maxv = 0;
while(q.size()){
maxv = max(maxv, -q.top().second); q.pop();
}
minv = min(minv, maxv);
}
return minv;
}
int naive(){
vector<pair<int,int> > v0,v;
REP(i,N) v0.push_back(mp(A[i],0));
sort(v0.begin(), v0.end());
int minv = 1<<29;
REP(i,N){
v = v0;
REP(j,N){
int add = B[(i+j)%N]/2;
v[0].first += add;
v[0].second++;
sort(v.begin(), v.end());
}
int maxv = 0;
REP(j,N) maxv = max(maxv, v[j].second);
//REP(j,N) cerr<<"("<<v[j].first<<","<<v[j].second<<"),"; cerr << endl;
minv = min(minv, maxv);
}
return minv;
}
int main(){
cin >> N;
if(N > 1500){ cerr << "error" << endl; return 1; }
REP(i,N){ cin >> A[i]; if(A[i] > 10000){ cerr << "error" << endl; return 1; } }
REP(i,N){ cin >> B[i]; if(B[i] > 10000){ cerr << "error" << endl; return 1; } }
cout << solve() << endl;
// cout << naive() << endl;
return 0;
}