This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |