#include <bits/stdc++.h>
#include "bubblesort2.h"
using namespace std;
typedef vector <int> vi;
const int MAXN = 2005;
int n, q;
int a[MAXN], br[MAXN];
void upd (int pos, int val) {
for (int i = pos + 1; i < n; i++) {
if (a[pos] > a[i]) br[i]--;
if (val > a[i]) br[i]++;
}
a[pos] = val;
br[pos] = 0;
for (int i = 0; i < pos; i++) {
if (a[i] > a[pos]) br[pos]++;
}
}
int solve () {
int mx = 0;
for (int i = 0; i < n; i++) {
mx = max(mx, br[i]);
}
return mx;
}
vi countScans (vi A, vi X, vi V) {
n = A.size(), q = X.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (a[j] > a[i]) br[i]++;
}
}
vi sol;
for (int i = 0; i < q; i++) {
upd(X[i], V[i]);
sol.push_back(solve());
}
return sol;
}
# |
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 |
Runtime error |
922 ms |
1392 KB |
Execution killed with signal 11 |
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 |
- |