#include "bubblesort2.h"
#include <set>
#include <map>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <cmath>
using namespace std;
int n, q;
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
vector<int> ans;
n = A.size();
q = X.size();
for(int i=0;i<q;i++){
A[X[i]] = V[i];
vector<int> srt;
for(int j=0;j<n;j++) srt.push_back(A[j]);
sort(srt.begin(), srt.end());
map<int, int> seen_before;
for(int j=0;j<n;j++) seen_before[A[j]] = 0;
int mx = -1;
for(int j=0;j<n;j++){
vector<int>::iterator it;
it = lower_bound(srt.begin(), srt.end(), A[j]);
int x = it-srt.begin();
mx = max(mx, ((int) round(fabs(x+seen_before[A[j]]-j))));
seen_before[A[j]]++;
}
ans.push_back(mx);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
138 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
138 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9060 ms |
1312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
138 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |