#include "bits/stdc++.h"
using namespace std;
#define intt long long
#define fi first
#define se second
const intt mxN = 1e5 + 5;
const intt LG = 20;
const intt inf = 1e18;
intt n;
vector<intt> a(mxN);
multiset<intt> mst;
void _() {
cin >> n;
a.resize(n);
for(intt &i : a) cin >> i;
reverse(a.begin(), a.end());
for(intt i = 0; i < n; i++) {
if(!mst.empty()) {
if(mst.find(a[i]-1) != mst.end()) {
mst.erase(mst.find(a[i]-1));
}
}
mst.insert(a[i]);
}
cout << mst.size() << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
intt t = 1, buu = 1;
// cin >> t;
while(t--){
// cout << "Case #" << buu++ << ": ";
_();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |