# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
746484 | nguyentunglam | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 6363 ms | 12828 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 1e5 + 01;
int f[N];
vector<int> countScans(vector<int> a, vector<int> pos, vector<int> val) {
vector<int> ans(pos.size());
int n = a.size();
for(int j = 0; j < n; j++) for(int k = 0; k < j; k++) f[j] += (a[j] < a[k]);
for(int i = 0; i < pos.size(); i++) {
int idx = pos[i];
for(int j = idx + 1; j < n; j++) f[j] -= (a[j] < a[idx]);
a[idx] = val[i];
for(int j = idx + 1; j < n; j++) f[j] += (a[j] < a[idx]);
f[idx] = 0;
for(int j = 0; j < idx; j++) f[idx] += (a[idx] < a[j]);
for(int j = 0; j < n; j++) ans[i] = max(ans[i], f[j]);
}
return ans;
}
#ifdef ngu
int main() {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
int n, q; cin >> n >> q;
vector<int> a(n), x(q), v(q);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < q; i++) cin >> x[i] >> v[i];
vector<int> ret = countScans(a, x, v);
for(int &j : ret) cout << j << endl;
}
#endif // ngu
컴파일 시 표준 에러 (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... |