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>
#define int long long
// #define ll long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
const int oo = 1e18 + 9;
const int MAX = 1e6 + 5, LOGMAX = 20, B = 800, MOD = 1e9 + 7;
vector<int> v;
void solve(){
int q; cin >> q;
while(q--){
int p, x; cin >> p >> x;
v.insert(v.begin() + p - 1, x);
vector<int> d;
for(int i = 0; i < v.size(); i++){
int id = lower_bound(all(d), v[i]) - d.begin();
if(id == d.size()) d.push_back(v[i]);
else d[id] = v[i];
}
cout << d.size() << '\n';
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
while(t--) solve();
}
Compilation message (stderr)
Main.cpp: In function 'void solve()':
Main.cpp:19:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
Main.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | if(id == d.size()) d.push_back(v[i]);
| ~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |