結果
| 問題 |
No.711 競技レーティング単調増加
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-30 16:05:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,636 bytes |
| コンパイル時間 | 1,896 ms |
| コンパイル使用メモリ | 203,792 KB |
| 最終ジャッジ日時 | 2025-01-06 15:08:33 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <typename T>
class Array : public vector<T> {
public:
using vector<T>::vector;
using vector<T>::begin;
using vector<T>::end;
using vector<T>::push_back;
template <typename R>
Array<R> map(function<R(T)> f) {
Array<R> res(end() - begin());
for (auto it = begin(); it != end(); ++it) res[it - begin()] = f(*it);
return res;
}
Array<T> select(function<bool(T)> f) {
Array<T> res;
for (auto it = begin(); it != end(); ++it)
if (f(*it)) res.push_back(*it);
return res;
}
template <typename R>
R reduce(R u, function<R(R, T)> f) {
for (auto it = begin(); it != end(); ++it) u = f(u, *it);
return u;
}
template <typename U>
Array<pair<T, U>> zip(const Array<U> &b) {
assert(end() - begin() == b.end() - b.begin());
Array<pair<T, U>> res;
for (auto it = begin(); it != end(); ++it)
res.push_back({*it, b[it - begin()]});
return res;
}
Array<T> iota(T st) {
Array<T> res(end() - begin());
::iota(res.begin(), res.end(), st);
return res;
}
};
signed main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
Array<int> A(N);
for (int i = 0; i < N; ++i) cin >> A[i];
Array<int> a = A.zip(Array<int>(N).iota(0))
.template map<int>([](pair<int, int> p) { return p.first - p.second; })
.select([](int x) { return -1 < x; });
Array<int> dp(N, 0x3f3f3f3f);
for (int v : a) *upper_bound(dp.begin(), dp.end(), v) = v;
size_t lis = lower_bound(dp.begin(), dp.end(), 0x3f3f3f3f) - dp.begin();
cout << N - lis << endl;
return 0;
}