結果
| 問題 |
No.711 競技レーティング単調増加
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2017-05-23 01:09:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 1,640 ms |
| コンパイル使用メモリ | 177,360 KB |
| 実行使用メモリ | 13,752 KB |
| 最終ジャッジ日時 | 2024-09-19 10:35:01 |
| 合計ジャッジ時間 | 5,661 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 TLE * 1 -- * 25 |
ソースコード
// O(n^2) のTLE解を枝刈りしたやつ。まあまあ早い
#include <bits/stdc++.h>
using namespace std;
int solve() {
int n;
cin >> n;
vector<int> A(n);
for (int i = 0; i < n; i++) cin >> A[i];
const int inf = 1e9 + 1e6;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q1, q2;
auto &cur = q1;
auto &nex = q2;
cur.emplace(0, 0);
for (int i = 0; i < n; i++) {
int las = inf;
int pre = inf;
while (!cur.empty()) {
int c, l;
tie(c, l) = cur.top();
cur.pop();
if (l > pre) continue;
pre = l;
if (l < A[i]) {
if (A[i] < las) {
nex.emplace(c, A[i]);
las = A[i];
}
}
if (l + 1 < las) {
nex.emplace(c + 1, l + 1);
las = l + 1;
}
}
swap(cur, nex);
}
int ans = cur.top().first;
return ans;
}
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
cout << solve() << endl;
return 0;
}
しらっ亭