This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("Ofast")
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
const int N = 8000, inf = INT_MAX;
int n;
vector<int> a;
vector<pair<int, int>> b;
int solve() {
for (int i = 0; i < n; i++) {
b[i] = make_pair(a[i], i);
}
sort(all(b));
int mx = 0;
int mn = inf;
for (int i = n-1; i >= 0; i--) {
mn = min(mn, a[i]);
if (mn < a[i]) continue;
int idx = lower_bound(all(b), make_pair(a[i], i)) - b.begin();
mx = max(mx, i - idx);
}
return mx;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
n = A.size();
int q = X.size();
vector<int> ans(q);
a.resize(n);
for (int i = 0; i < n; i++) {
a[i] = A[i];
}
b.resize(n);
for (int j = 0; j < q; j++) {
a[X[j]] = V[j];
ans[j] = solve();
}
return ans;
}
# | 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... |