結果
問題 |
No.9 モンスターのレベル上げ
|
ユーザー |
![]() |
提出日時 | 2017-01-15 00:17:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,298 bytes |
コンパイル時間 | 597 ms |
コンパイル使用メモリ | 75,496 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 12:56:21 |
合計ジャッジ時間 | 4,022 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 20 |
ソースコード
#include<iostream> #include<queue> using namespace std; int n; int *a, *b; int i,j; int ans = 1 << 16; void scan(); void solve(); int cnt(int index); void write(); struct monstar { int battle; int level; }; struct temp :less<monstar> { bool operator()(const monstar &a, const monstar &b) { if (a.level != b.level) { return a.level < b.level; } else { return a.battle > b.battle; } } }; int main(void) { scan(); solve(); write(); return 0; } void scan() { cin >> n; a = new int[n]; b = new int[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { cin >> b[i]; } } void solve() { for (j = 0; j < n; j++) { int a = cnt(j); if (j < ans) { ans = j; } } } void write() { cout << ans << endl; } int cnt(int index) { priority_queue<monstar, vector<monstar>, temp> q; for (i = 0; i < n; i++) { struct monstar add = { 0,a[i] }; q.push(add); } for (i = index; i < n; i++) { monstar cp = q.top(); q.pop(); cp.battle++; cp.level = b[i] / 2; q.push(cp); } for (i = 0; i < index; i++) { monstar cp = q.top(); q.pop(); cp.battle++; cp.level = b[i] / 2; q.push(cp); } int max = 0; for (i = 0; i < n; i++) { monstar m = q.top(); q.pop(); if (max < m.battle) { max = m.battle; } } return max; }