Submission #1089575

#TimeUsernameProblemLanguageResultExecution timeMemory
1089575VMaksimoski008Bubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9041 ms2776 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int maxn = 5e5 + 5; struct BIT { int n; vector<int> tree; BIT(int _n) : n(_n+10), tree(_n+60) {} void update(int p) { for(p++; p<n; p+=p&-p) tree[p]++; } int query(int p) { int ans = 0; for(p++; p>0; p-=p&-p) ans += tree[p]; return ans; } void clear() { for(int &x : tree) x = 0; } }; vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) { int n = A.size(), q = X.size(); vector<int> ans(q); BIT bit(n); for(int it=0; it<q; it++) { A[X[it]] = V[it]; bit.clear(); vector<pii> vec; for(int i=0; i<n; i++) vec.push_back({ A[i], i }); sort(vec.rbegin(), vec.rend()); for(auto &[val, id] : vec) { ans[it] = max(ans[it], bit.query(id)); bit.update(id); } } 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...