結果
| 問題 |
No.711 競技レーティング単調増加
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2018-06-29 23:17:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 896 bytes |
| コンパイル時間 | 718 ms |
| コンパイル使用メモリ | 87,860 KB |
| 実行使用メモリ | 12,560 KB |
| 最終ジャッジ日時 | 2024-07-01 00:14:38 |
| 合計ジャッジ時間 | 2,984 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int INF = (int)1 << 62;
int getLIS(vector<pair<int,int> > &a)
{
int N = a.size();
pair<int, int> inf;
inf = make_pair(INF, INF);
vector<pair<int,int> > dp(N, inf);
for (int i = 0; i<N; ++i) {
*lower_bound(dp.begin(), dp.begin() + N, a[i]) = a[i];
}
return lower_bound(dp.begin(), dp.begin() + N, inf) - dp.begin();
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<pair<int,int> > A(N);
vector<pair<int, int> > B;
int res = 0;
for (int i = 0; i < N; i++) {
cin >> A[i].first;
A[i].first -= i;
A[i].second = i;
if (A[i].first > 0) {
B.push_back(A[i]);
}
}
cout << N - getLIS(B) << endl;
}
ats5515