#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> st;
void update(int pos, int val, int node=1, int tl=0, int tr=n-1){
if (tl == tr){
st[node] = val;
return;
}
int tm = (tl+tr)/2;
if (pos <= tm) update(pos, val, node*2, tl, tm);
else update(pos, val, node*2+1, tm+1, tr);
st[node] = max(st[node*2], st[node*2+1]);
}
int query(int l, int r, int node=1, int tl=0, int tr=n-1){
if (l <= tl && tr <= r) return st[node];
int tm = (tl+tr)/2;
int res = 0;
if (l <= tm) res = max(res, query(l, r, node*2, tl, tm));
if (tm+1 <= r) res = max(res, query(l, r, node*2+1, tm+1, tr));
return res;
}
int main(){
int x;
cin >> n >> x;
vector<int> v(n);
for (int i=0; i<n; i++) cin >> v[i];
st.resize(4*n, 0);
vector<pair<int,int>> p(n);
for (int i=0; i<n; i++) p[i] = {v[i], -i};
sort(p.begin(), p.end());
for (int i=n-1; i>=0; i--){
int j = -p[i].second;
int bsf = query(j, n-1);
update(j, bsf+1);
}
cout << st[1] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
5716 KB |
Output is correct |
2 |
Correct |
114 ms |
7764 KB |
Output is correct |
3 |
Correct |
120 ms |
7732 KB |
Output is correct |
4 |
Correct |
124 ms |
7764 KB |
Output is correct |
5 |
Correct |
87 ms |
7064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1628 KB |
Output is correct |
2 |
Correct |
27 ms |
2304 KB |
Output is correct |
3 |
Correct |
29 ms |
2140 KB |
Output is correct |
4 |
Incorrect |
19 ms |
1956 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
3156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |