Submission #1212127

#TimeUsernameProblemLanguageResultExecution timeMemory
1212127catch_me_if_you_canBubble Sort 2 (JOI18_bubblesort2)C++20
38 / 100
9092 ms1452 KiB
#include<bits/stdc++.h> #include "bubblesort2.h" using namespace std; #define in array<int, 2> #define pb push_back #define pob pop_back #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) const int MX = 2e5+5; const int INF = 1e9+1e8; struct fenwick { int N; vector<int> fen; void init(int n) { N = n+3; fen.assign(N+1, 0); return; } void add(int x) { for(int t = x; t < N; t+=(t&-t)) fen[t]++; return; } int val(int x = -1) { if(x == -1) x = N-1; int ret = 0; for(int t = x; t; t-=(t&-t)) ret+=fen[t]; return ret; } }; vector<int> countScans(vector<int> A, vector<int> x, vector<int> v) { int n = A.size(); vector<int> G = A; for(auto s: v) G.pb(s); sort(G.begin(), G.end()); vector<int> H; H.pb(-INF); for(auto s: G) { if(s != H.back()) H.pb(s); } vector<int> a(n+1); for(int i = 1; i <= n; i++) a[i] = lower_bound(H.begin(), H.end(), A[i-1]) - H.begin(); int q = x.size(); for(int i = 0; i < q; i++) v[i] = lower_bound(H.begin(), H.end(), v[i]) - H.begin(); int N = H.size()-1; fenwick work; vector<int> ans(q); for(int s = 0; s < q; s++) { a[x[s]+1] = v[s]; work.init(N); int Ans = 0; for(int i = 1; i <= n; i++) { Ans = max(Ans, work.val()-work.val(a[i])); work.add(a[i]); } ans[s] = Ans; } 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...