Submission #1037901

#TimeUsernameProblemLanguageResultExecution timeMemory
1037901javotazLIS (INOI20_lis)C++17
20 / 100
58 ms628 KiB
// In the Name of Allah

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

#pragma GCC optimize("Ofast,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,avx,avx2,sse4.2,popcnt,tune=native")

typedef long long ll;

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define int long long

const int N = 2e3 + 12;
int a[N], n, dp[N];

int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	if (q > 2000)
		return 0;
	while (q--) {
		int p, x;
		cin >> p >> x;
		a[++n] = x;
		for (int i = n; i > p; i--)
			swap(a[i], a[i - 1]);
		memset(dp, 127, sizeof dp);
		int ans = 0;
		for (int i = 0; i <= n; i++)
			dp[lower_bound(dp, dp + n + 1, a[i]) - dp] = a[i];
		for (int i = 0; i <= n; i++)
			if (dp[i] <= 10000000)
				ans = i;
		cout << ans << '\n';
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...