This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1e9 + 100;
const ll LINF = 1e18 + 100;
#ifdef DEBUG
#define dbg(x) cout << #x << " = " << (x) << endl << flush;
#define dbgr(s, f) { cout << #s << ": "; for (auto _ = (s); _ != (f); _++) cout << *_ << ' '; cout << endl << flush; }
#else
#define dbg(x) ;
#define dbgr(s, f) ;
#endif
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const int MAXN = 1000100;
int n, p[MAXN], x[MAXN];
vector<int> vec;
int dp[MAXN];
inline int getlis(void)
{
fill(dp, dp + MAXN, INF);
dp[0] = -INF;
for (int u : vec)
{
int pos = lower_bound(dp, dp + MAXN, u) - dp;
dp[pos] = u;
}
int ans = lower_bound(dp, dp + MAXN, INF) - dp - 1;
return ans;
}
int32_t main(void)
{
fast_io;
cin >> n;
FOR(i, 0, n)
{
cin >> p[i] >> x[i];
p[i]--;
vec.insert(vec.begin() + p[i], x[i]);
cout << getlis() << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |