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 "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
int last[500005];
map<int, int> mp;
vector<int> ans;
vector<int> countScans(vector<int> a, vector<int> x, vector<int> y)
{
int n=a.size(), m=x.size(), sz=0;
for (int i=0; i<n; i++)
mp[a[i]]=0;
for (auto it=mp.begin(); it!=mp.end(); it++)
mp[it->first]=(++sz);
for (int i=0; i<n; i++)
last[a[i]=mp[a[i]]]=i;
for (int i=0; i<m; i++)
{
a[x[i]]=mp[y[i]];
int mx=0;
for (int j=0; j<sz; j++)
{
int cnt=0;
for (int k=0; k<last[j]; k++)
if (a[k]>a[last[j]])
cnt++;
mx=max(mx, cnt);
}
ans.push_back(mx);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |