이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bubblesort2.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
vector <int> countScans(vector <int> a, vector <int> x, vector <int> v) {
int n = a.size(), q = x.size();
if (n > 8000 || q > 8000)
return {};
vector <int> cnt, anss = {}; cnt.assign(n, 0);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (a[i] > a[j])
cnt[j]++;
for (int i = 0; i < q; i++) {
int pos = x[i], val = v[i];
for (int j = pos + 1; j < n; j++)
if (a[i] <= a[j] && a[j] < val)
cnt[j]++;
else if (val <= a[j] && a[j] < a[i])
cnt[j]--;
cnt[pos] = 0;
for (int j = 0; j < pos; j++)
if (a[j] > val)
cnt[pos]++;
a[pos] = val;
int ans = 0;
for (int j = 0; j < n; j++)
ans = max(ans, cnt[j]);
anss.pb(ans);
}
return anss;
}
# | 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... |