# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
539131 | LucaDantas | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 9085 ms | 4308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "bubblesort2.h"
using namespace std;
constexpr int maxn = 5e5+10;
struct BIT {
int bit[maxn];
void upd(int x, int v) {
for(; x > 0; x -= x&-x)
bit[x] += v;
}
int query(int x) {
int ans = 0;
for(; x < maxn; x += x&-x)
ans += bit[x];
return ans;
}
void clear() { memset(bit, 0, sizeof bit); }
} bit;
// fazer o brutao pra checar se essa ideia ta certo e se eu codo ela pra full
int calc(const vector<int>& A) {
int ans = 0;
bit.clear();
for(int i = 0; i < (int)A.size(); i++)
ans = max(ans, bit.query(A[i]+1)), bit.upd(A[i], 1);
return ans;
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q = (int)X.size(), N = (int)A.size();
std::vector<int> answer(Q);
for(int q = 0; q < Q; q++) {
A[X[q]] = V[q];
answer[q] = calc(A);
}
return answer;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |