#include <bits/stdc++.h>
using namespace std;
//BIT Fenwick tree
int n ;
int bit[2000003]={0};
void add(int e,int v){
while(e<=(n+1)*2){
bit[e]+=v;
e+=e&-e;
}
}
long long sum(int e){
long long res = 0;
while(e>=1){
res+=bit[e];
e -= e&-e;
}
return res;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
vector<long long> v,w,so;v.push_back(2);
for(int i = 0;i<n;i++){
int x;cin>>x;
w.push_back(x);
so.push_back(x);
}
sort(so.begin(),so.end());
int z = 2;
map<int,int>cmp;
for(int i = 0;i<n;i++){
cmp[so[i]] = z++;
if(i&&so[i]==so[i-1])z--;
}
for(int i = 0;i<n;i++){
v.push_back(cmp[w[i]]*2);
}
for(int i = 0;i<n;i++){
if(v[i]<v[i+1]){
add(v[i+1],-1);
add(v[i],1);
}
}
long long ma = 0;
for(int i = 2;i<=cmp[so[n-1]]*2;i++){
ma = max(ma,sum(i));
}
cout<<ma<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
3528 KB |
Output is correct |
2 |
Correct |
16 ms |
3520 KB |
Output is correct |
3 |
Correct |
20 ms |
3528 KB |
Output is correct |
4 |
Correct |
16 ms |
3568 KB |
Output is correct |
5 |
Correct |
17 ms |
3532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
8324 KB |
Output is correct |
2 |
Correct |
67 ms |
8404 KB |
Output is correct |
3 |
Correct |
93 ms |
8380 KB |
Output is correct |
4 |
Correct |
84 ms |
8332 KB |
Output is correct |
5 |
Correct |
83 ms |
8360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
555 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
55248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |