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>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 8005;
int n, q, ans[N];
vector<int> countScans(vector<int> a, vector<int> x, vector<int> v) {
//Count for each i how many numbers to its left > a[i]
n = a.size(), q = x.size();
vector<int> lol;
fw (i, 0, n) {
fw (j, i + 1, n) if (a[i] > a[j]) ans[j]++;
}
fw (i, 0, q) {
int pos = x[i], val = v[i];
ans[pos] = 0;
fw (j, 0, pos) if (a[j] > val) ans[pos]++;
fw (j, pos + 1, n) {
if (a[pos] > a[j]) ans[j]--;
if (val > a[j]) ans[j]++;
}
a[pos] = val;
int res = 0;
fw (j, 0, n) res = max(res, ans[j]);
lol.pb(res);
}
return lol;
}
//signed main() {
// #ifdef BLU
// in("blu.inp");
// #endif
// ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// vector<int> hi = countScans({1, 2, 3, 4}, {0, 3}, {1, 3});
// fa (i, hi) cout << i << "\n";
// return 0;
//}
# | 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... |