#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++) {
a[i] = A[i];
}
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 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
30 ms |
492 KB |
Output is correct |
4 |
Correct |
30 ms |
492 KB |
Output is correct |
5 |
Correct |
25 ms |
492 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
20 ms |
492 KB |
Output is correct |
8 |
Correct |
22 ms |
492 KB |
Output is correct |
9 |
Correct |
25 ms |
492 KB |
Output is correct |
10 |
Correct |
21 ms |
492 KB |
Output is correct |
11 |
Correct |
21 ms |
492 KB |
Output is correct |
12 |
Correct |
21 ms |
492 KB |
Output is correct |
13 |
Correct |
20 ms |
492 KB |
Output is correct |
14 |
Correct |
20 ms |
492 KB |
Output is correct |
15 |
Correct |
21 ms |
492 KB |
Output is correct |
16 |
Correct |
19 ms |
492 KB |
Output is correct |
17 |
Correct |
19 ms |
492 KB |
Output is correct |
18 |
Correct |
19 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
30 ms |
492 KB |
Output is correct |
4 |
Correct |
30 ms |
492 KB |
Output is correct |
5 |
Correct |
25 ms |
492 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
20 ms |
492 KB |
Output is correct |
8 |
Correct |
22 ms |
492 KB |
Output is correct |
9 |
Correct |
25 ms |
492 KB |
Output is correct |
10 |
Correct |
21 ms |
492 KB |
Output is correct |
11 |
Correct |
21 ms |
492 KB |
Output is correct |
12 |
Correct |
21 ms |
492 KB |
Output is correct |
13 |
Correct |
20 ms |
492 KB |
Output is correct |
14 |
Correct |
20 ms |
492 KB |
Output is correct |
15 |
Correct |
21 ms |
492 KB |
Output is correct |
16 |
Correct |
19 ms |
492 KB |
Output is correct |
17 |
Correct |
19 ms |
492 KB |
Output is correct |
18 |
Correct |
19 ms |
492 KB |
Output is correct |
19 |
Runtime error |
88 ms |
1260 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1022 ms |
1336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
30 ms |
492 KB |
Output is correct |
4 |
Correct |
30 ms |
492 KB |
Output is correct |
5 |
Correct |
25 ms |
492 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
20 ms |
492 KB |
Output is correct |
8 |
Correct |
22 ms |
492 KB |
Output is correct |
9 |
Correct |
25 ms |
492 KB |
Output is correct |
10 |
Correct |
21 ms |
492 KB |
Output is correct |
11 |
Correct |
21 ms |
492 KB |
Output is correct |
12 |
Correct |
21 ms |
492 KB |
Output is correct |
13 |
Correct |
20 ms |
492 KB |
Output is correct |
14 |
Correct |
20 ms |
492 KB |
Output is correct |
15 |
Correct |
21 ms |
492 KB |
Output is correct |
16 |
Correct |
19 ms |
492 KB |
Output is correct |
17 |
Correct |
19 ms |
492 KB |
Output is correct |
18 |
Correct |
19 ms |
492 KB |
Output is correct |
19 |
Runtime error |
88 ms |
1260 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |