結果
| 問題 |
No.9 モンスターのレベル上げ
|
| コンテスト | |
| ユーザー |
opqopq_
|
| 提出日時 | 2015-05-11 21:17:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 305 ms / 5,000 ms |
| コード長 | 884 bytes |
| コンパイル時間 | 360 ms |
| コンパイル使用メモリ | 43,904 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 22:37:10 |
| 合計ジャッジ時間 | 3,785 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:21:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | for (int i = 0; i < N; i++) scanf("%d", A + i);
| ~~~~~^~~~~~~~~~~~~
main.cpp:22:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | for (int i = 0; i < N; i++) scanf("%d", B + i);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <queue>
using namespace std;
#define N_MAX 1500
struct State {
int level, turn;
State(int l) : level(l), turn(0) {}
bool operator < (const State& r) const {
if (level != r.level) return level > r.level;
return turn > r.turn;
}
};
int N;
int A[N_MAX], B[N_MAX];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) scanf("%d", A + i);
for (int i = 0; i < N; i++) scanf("%d", B + i);
int res = N_MAX + 1;
priority_queue<State> pq;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) pq.emplace(A[j]);
int j = i, cnt = 0;
while (cnt != N) {
State s = pq.top();
pq.pop();
s.level += B[j] / 2;
s.turn++;
pq.push(s);
j = (j + 1) % N;
cnt++;
}
int maxi = 0;
while (pq.size()) {
maxi = max(maxi, pq.top().turn);
pq.pop();
}
res = min(res, maxi);
}
printf("%d\n", res);
return 0;
}
opqopq_