# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894667 | lunaTu | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 9067 ms | 2060 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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#include "bubblesort2.h"
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N = 5e4 + 1;
int A[N];
int ans[N];
int add(int n, int i, int x) {
int mx = 0;
for (int j = i + 1; j < n; j++) {
if (A[j] < A[i]) ans[j]--;
if (A[j] < x) ans[j]++;
mx = max(mx, ans[j]);
}
ans[i] = 0;
for (int j = i - 1; j >= 0; j--) {
if (A[j] > x) ans[i]++;
mx = max(mx, ans[j]);
}
A[i] = x;
return max(mx, ans[i]);
}
vector<int> countScans(vector<int> a, vector<int> x, vector<int> v){
int n = a.size();
for (int i = 0; i < n; i++) {
int w = add(n, i, a[i]);
}
int q = x.size();
vector<int> answer(q);
for (int j = 0; j < q; j++) answer[j] = add(n, x[j], v[j]);
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... |