結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2014-10-05 15:59:40 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 388 ms / 5,000 ms |
コード長 | 1,542 bytes |
コンパイル時間 | 923 ms |
コンパイル使用メモリ | 74,824 KB |
実行使用メモリ | 4,504 KB |
最終ジャッジ日時 | 2023-09-06 03:05:47 |
合計ジャッジ時間 | 5,402 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 388 ms
4,380 KB |
testcase_03 | AC | 310 ms
4,376 KB |
testcase_04 | AC | 161 ms
4,380 KB |
testcase_05 | AC | 105 ms
4,504 KB |
testcase_06 | AC | 37 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 48 ms
4,380 KB |
testcase_09 | AC | 378 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 307 ms
4,376 KB |
testcase_12 | AC | 236 ms
4,376 KB |
testcase_13 | AC | 187 ms
4,380 KB |
testcase_14 | AC | 380 ms
4,380 KB |
testcase_15 | AC | 344 ms
4,380 KB |
testcase_16 | AC | 7 ms
4,380 KB |
testcase_17 | AC | 218 ms
4,380 KB |
testcase_18 | AC | 182 ms
4,380 KB |
testcase_19 | AC | 5 ms
4,380 KB |
ソースコード
#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; }