結果
| 問題 | No.711 競技レーティング単調増加 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-30 01:53:17 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 782 bytes |
| 記録 | |
| コンパイル時間 | 1,801 ms |
| コンパイル使用メモリ | 213,496 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-07 00:29:25 |
| 合計ジャッジ時間 | 5,171 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 27 |
ソースコード
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;
template <typename T>
vector<T> longest_increasing_subsequence(vector<T> const & xs) {
vector<T> l; // l[i] is the last element of the increasing subsequence whose length is i+1
l.push_back(xs.front());
for (auto && x : xs) {
auto it = lower_bound(l.begin(), l.end(), x);
if (it == l.end()) {
l.push_back(x);
} else {
*it = x;
}
}
return l;
}
int main() {
// input
int n; cin >> n;
vector<int> a(n);
REP (i, n) cin >> a[i];
// solve
REP (i, n) a[i] -= 1;
int answer = n - longest_increasing_subsequence(a).size();
// output
cout << answer << endl;
return 0;
}