#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(a) (int)(a.size());
typedef pair<int,int> pii;
vector<int>bit(100000);
int n;
void upd(int pos,int val){
for(int i=pos;i<=n;i+=i&(-i))bit[i]+=val;
}
int query(int pos){
int res = 0;
while(pos){
res+=bit[pos];
pos-=pos&(-pos);
}
return res;
}
vector<int> countScans(vector<int> a,vector<int> x,vector<int>v){
int q=sz(x);
n = sz(a);
vector<int> answer(q);
vector<pii>b(n);
for(int i=0;i<n;i++){
b[i].fi = a[i];
b[i].se = i+1;
}
for (int j=0;j<q;j++) {
for(int i=1;i<=n;i++)bit[i] = 0;
b[x[j]].fi = v[j];
sort(b.begin(),b.end());
int mx = 0;
for(int i=0;i<n;i++){
mx = max(query(n)-query(b[i].se),mx);
upd(b[i].se,1);
}
answer[j] = mx;
}
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4470 ms |
1240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |