# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
746490 | 2023-05-22T14:09:38 Z | nguyentunglam | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 9000 ms | 2060 KB |
#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 < n; k++) f[j] += (a[j] >= a[k]); for(int i = 0; i < pos.size(); i++) { int idx = pos[i]; for(int j = 0; 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 < n; j++) f[idx] += (a[idx] >= a[j]); for(int j = 0; j < n; j++) ans[i] = max(ans[i], j + 1 - 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
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 905 ms | 632 KB | Output is correct |
2 | Correct | 4445 ms | 1236 KB | Output is correct |
3 | Execution timed out | 9046 ms | 2060 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |