Submission #496079

#TimeUsernameProblemLanguageResultExecution timeMemory
496079600MihneaBubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9070 ms10840 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int NAX = (int) 1e6 + 7; int N; int coef[NAX]; bool valid[NAX]; vector<int> innterCountScans(vector<ll> a, vector<int> pos, vector<ll> value) { int n = (int) a.size(); int q = (int) pos.size(); for (int i = 0; i < n; i++) { a[i] = a[i] * (ll) (n + 1) + i; } assert(q == (int) value.size()); for (int it = 0; it < q; it++) { value[it] = value[it] * (ll) (n + 1) + pos[it]; } map<ll, int> mp; for (auto &x : a) { mp[x] = 0; } for (auto &x : value) { mp[x] = 0; } { int ij = 0; for (auto &it : mp) { it.second = ++ij; } N = ij; assert(N <= n + q); } for (auto &x : a) { x = mp[x]; } for (auto &x : value) { x = mp[x]; } for (int i = 0; i < n; i++) { valid[a[i]] = 1; coef[a[i]] = i; } vector<int> sol; for (int it = 0; it < q; it++) { valid[a[pos[it]]] = 0; a[pos[it]] = value[it]; valid[a[pos[it]]] = 1; coef[a[pos[it]]] = pos[it]; int cnt = 0, MX = 0; for (int i = 1; i <= N; i++) { if (valid[i]) { cnt++; MX = max(MX, coef[i] - cnt); } } sol.push_back(MX + 1); } return sol; } vector<int> countScans(vector<int> a, vector<int> b, vector<int> c) { vector<ll> X, Z; for (auto &it : a) { X.push_back(it); } for (auto &it : c) { Z.push_back(it); } return innterCountScans(X, b, Z); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...