結果

問題 No.711 競技レーティング単調増加
ユーザー しらっ亭
提出日時 2017-10-02 11:58:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 169,288 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 22:40:17
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int solve() {
	int n;
	cin >> n;
	vector<int> A;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a - i > 0) {
			A.emplace_back(a - i);
		}
	}

	int m = A.size();
	const int inf = 1e9;
	vector<int> dp(m + 1, inf);
	for (int i = 0; i < m; i++) *upper_bound(dp.begin(), dp.end(), A[i]) = A[i];
	int lis = lower_bound(dp.begin(), dp.end(), inf) - dp.begin();

	return n - lis;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << solve() << endl;
	return 0;
}
0