Submission #633547

#TimeUsernameProblemLanguageResultExecution timeMemory
633547ArinoorBubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9011 ms2888 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define fi first #define se second #define bug(x) cerr << #x << " : " << x << '\n' typedef pair<int, int> pii; const int maxn = 2e5 + 10; int n, q; int a[maxn]; int fen[maxn]; void add(int i){ for(; i <= n; i += i & -i) fen[i] ++; } int get(int i){ int res = 0; for(; i; i -= i & -i) res += fen[i]; return res; } int solve(){ for(int i = 1; i <= n; i ++) fen[i] = 0; vector<pii> V; for(int i = 0; i < n; i ++){ V.pb(mp(a[i], i + 1)); } sort(all(V)); int ans = 0; for(int i = n - 1; ~i; i --){ int ind = V[i].se; ans = max(ans, get(ind)); add(ind); } return ans; } vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){ n = A.size(); q = X.size(); for(int i = 0; i < n; i ++) a[i] = A[i]; vector<int> ans; for(int i = 0; i < q; i ++){ a[X[i]] = V[i]; ans.pb(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...