#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int maxn = 5e5 + 5;
int tree[maxn], n;
void update(int p, int v) {
for(p++; p<n; p+=p&-p) tree[p] += v;
}
int query(int p) {
int ans = 0;
for(p++; p; p-=p&-p) ans += tree[p];
return ans;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) {
n = A.size(); int q = X.size();
vector<int> ans(q);
for(int it=0; it<q; it++) {
A[X[it]] = V[it];
for(int i=0; i<n+5; i++) tree[i] = 0;
vector<pii> vec;
for(int i=0; i<n; i++) vec.push_back({ A[i], i });
sort(vec.begin(), vec.end(), [&](pii &a, pii &b) {
if(a.first != b.first) return a.first > b.first;
return a.second > b.second;
});
for(auto &[val, i] : vec) {
ans[it] = max(ans[it], query(i));
update(i, 1);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
452 KB |
Output is correct |
2 |
Correct |
38 ms |
344 KB |
Output is correct |
3 |
Correct |
259 ms |
508 KB |
Output is correct |
4 |
Correct |
259 ms |
344 KB |
Output is correct |
5 |
Correct |
250 ms |
560 KB |
Output is correct |
6 |
Correct |
162 ms |
564 KB |
Output is correct |
7 |
Correct |
204 ms |
348 KB |
Output is correct |
8 |
Correct |
232 ms |
348 KB |
Output is correct |
9 |
Correct |
260 ms |
348 KB |
Output is correct |
10 |
Correct |
235 ms |
508 KB |
Output is correct |
11 |
Incorrect |
228 ms |
348 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
452 KB |
Output is correct |
2 |
Correct |
38 ms |
344 KB |
Output is correct |
3 |
Correct |
259 ms |
508 KB |
Output is correct |
4 |
Correct |
259 ms |
344 KB |
Output is correct |
5 |
Correct |
250 ms |
560 KB |
Output is correct |
6 |
Correct |
162 ms |
564 KB |
Output is correct |
7 |
Correct |
204 ms |
348 KB |
Output is correct |
8 |
Correct |
232 ms |
348 KB |
Output is correct |
9 |
Correct |
260 ms |
348 KB |
Output is correct |
10 |
Correct |
235 ms |
508 KB |
Output is correct |
11 |
Incorrect |
228 ms |
348 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6176 ms |
1408 KB |
Output is correct |
2 |
Execution timed out |
9035 ms |
2604 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
452 KB |
Output is correct |
2 |
Correct |
38 ms |
344 KB |
Output is correct |
3 |
Correct |
259 ms |
508 KB |
Output is correct |
4 |
Correct |
259 ms |
344 KB |
Output is correct |
5 |
Correct |
250 ms |
560 KB |
Output is correct |
6 |
Correct |
162 ms |
564 KB |
Output is correct |
7 |
Correct |
204 ms |
348 KB |
Output is correct |
8 |
Correct |
232 ms |
348 KB |
Output is correct |
9 |
Correct |
260 ms |
348 KB |
Output is correct |
10 |
Correct |
235 ms |
508 KB |
Output is correct |
11 |
Incorrect |
228 ms |
348 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |