# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
650067 | 2022-10-12T08:28:26 Z | boris_mihov | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 9000 ms | 724 KB |
#include "bubblesort2.h" #include <algorithm> #include <iostream> #include <numeric> #include <vector> typedef long long llong; const int MAXN = 500000 + 10; const int INF = 1e9; int b[MAXN]; int a[MAXN], n; int smaller[MAXN]; std::vector <int> ans; int cnt; void calc() { for (int i = 1 ; i <= n ; ++i) b[i] = a[i]; cnt = 0; bool sorted = false; while (!sorted) { sorted = true; for (int i = 1 ; i <= n-1 ; ++i) { if (b[i] > b[i + 1]) { sorted = false; std::swap(b[i], b[i + 1]); } } cnt += !sorted; } } std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V) { n = A.size(); for (int i = 1 ; i <= n ; ++i) a[i] = A[i-1]; ans.resize(X.size()); for (int i = 0 ; i < X.size() ; ++i) { a[X[i] + 1] = V[i]; calc(); ans[i] = cnt; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 180 ms | 340 KB | Output is correct |
2 | Correct | 694 ms | 348 KB | Output is correct |
3 | Execution timed out | 9034 ms | 340 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 180 ms | 340 KB | Output is correct |
2 | Correct | 694 ms | 348 KB | Output is correct |
3 | Execution timed out | 9034 ms | 340 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 9020 ms | 724 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 180 ms | 340 KB | Output is correct |
2 | Correct | 694 ms | 348 KB | Output is correct |
3 | Execution timed out | 9034 ms | 340 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |