#include "bubblesort2.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
vector <int> countScans(vector <int> a, vector <int> x, vector <int> v) {
int n = a.size(), q = x.size();
if (n > 8000 || q > 8000)
return {};
vector <int> cnt, anss = {}; cnt.assign(n, 0);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (a[i] > a[j])
cnt[j]++;
for (int i = 0; i < q; i++) {
int pos = x[i], val = v[i];
for (int j = pos + 1; j < n; j++)
if (a[i] <= a[j] && a[j] < val)
cnt[j]++;
else if (val <= a[j] && a[j] < a[i])
cnt[j]--;
cnt[pos] = 0;
for (int j = 0; j < pos; j++)
if (a[j] > val)
cnt[pos]++;
a[pos] = val;
int ans = 0;
for (int j = 0; j < n; j++)
ans = max(ans, cnt[j]);
anss.pb(ans);
}
return anss;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |