#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
#ifdef CM
#include "debug.h"
#else
#define debug(...) 42
#endif
#define pb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define aura 1e18
#define pii pair<int,int>
void die(string S){puts(S.c_str());exit(0);}
// #define int long long
const int mod=998244353;
int binpow(int a,int b)
{
int res=1;
while(b)
{
if(b&1)
res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res%mod;
}
int inv(int x)
{
return binpow(x,mod-2);
}
void solve()
{
int q;
cin>>q;
vector<int>a;
int n=0;
while(q--)
{
int id,x;
cin>>id>>x;
id--;
a.insert(a.begin()+id,x); n++;
vector<int>dp;
for(int i=0;i<n;i++)
{
if(dp.empty() || a[i]>dp.back())
dp.pb(a[i]);
auto it=lower_bound(ALL(dp),a[i]);
dp[it-dp.begin()]=a[i];
}
cout<<sz(dp)<<'\n';
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
#ifdef CM
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
// cin>>t;
while(t--)
solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |