Submission #467737

#TimeUsernameProblemLanguageResultExecution timeMemory
467737kingfran1907Bubble Sort 2 (JOI18_bubblesort2)C++14
0 / 100
9021 ms716 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; typedef long long llint; const int maxn = 1e6+10; int n, q; int loga[maxn]; vector< int > v; void update(int x, int val) { for (x++; x < maxn; x += x & -x) loga[x] += val; } int query(int x) { int out = 0; for (x++; x > 0; x -= x & -x) out += loga[x]; return out; } int solve(vector< int > v) { vector< int > cp = v; sort(cp.begin(), cp.end()); //printf("solve: "); //for (int i = 0; i < v.size(); i++) // printf("%d ", v[i]); vector< bool > bio; for (int i = 0; i < n; i++) bio.push_back(false); int maxi = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (v[i] == cp[j] && !bio[j]) { maxi = max(maxi, abs(i - j)); bio[j] = true; break; } } } //printf("-- %d\n", maxi); return maxi; } vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){ n = A.size(); q = X.size(); vector< int > ans; for (int k = 0; k < q; k++) { A[X[k]] = V[k]; ans.push_back(solve(A)); } 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...