Submission #1012208

#TimeUsernameProblemLanguageResultExecution timeMemory
1012208d4xnBubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9019 ms1880 KiB
#pragma GCC optimize ("Ofast") #include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() const int N = 8000, inf = INT_MAX; int n; vector<int> a; vector<pair<int, int>> b; int solve() { for (int i = 0; i < n; i++) { b[i] = make_pair(a[i], i); } sort(all(b)); int mx = 0; int mn = inf; for (int i = n-1; i >= 0; i--) { mn = min(mn, a[i]); if (mn < a[i]) continue; int idx = lower_bound(all(b), make_pair(a[i], i)) - b.begin(); mx = max(mx, i - idx); } return mx; } vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){ n = A.size(); int q = X.size(); vector<int> ans(q); a.resize(n); for (int i = 0; i < n; i++) { a[i] = A[i]; } b.resize(n); for (int j = 0; j < q; j++) { a[X[j]] = V[j]; ans[j] = solve(); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...