# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1013624 | vjudge1 | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define mod 1000000007LL
#define inf 1e17
#define ll long long
using namespace std;
void printvec(vector<int> vec)
{
for (auto &&e : vec)
{
cout << e << ' ';
}
cout << endl;
}
vector<int> countScans(vector<int>& a, vector<int>& x, vector<int>& v)
{
vector<int> s;
multiset<int> a_sorted;
for (int i = 0; i < a.size(); i++)
{
a_sorted.insert(a[i]);
}
for (int j = 0; j < x.size(); j++)
{
a_sorted.erase(a_sorted.find(a[x[j]]));
a_sorted.insert(v[j]);
a[x[j]] = v[j];
// for (auto& e:a_sorted) cout << e << ' ';
// cout << endl;
map<ll,ll> ind;
ll i = 0;
for (auto it = a_sorted.begin(); it != a_sorted.end(); it++)
{
ind[*it] = i;
i++;
}
ll maxe = 0;
for (int i = 0; i < a.size(); i++)
{
if(i > ind[a[i]])
{
maxe = max(maxe, i - ind[a[i]]);
}
}
s.push_back(maxe);
}
return s;
}
// int main()
// {
// vector<int> A = {1, 2, 3, 4};
// vector<int> X = {0, 2};
// vector<int> V = {3, 1};
// vector<int> ans = countScans(A,X,V);
// printvec(ans);
// }