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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int , int> , null_type, less<pair<int , int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
std::vector<int> countScans(std::vector<int> a,std::vector<int> X,std::vector<int> V){
int Q=X.size();
int n = a.size();
std::vector<int> answer(Q);
priority_queue<int> q[101];
orderedSet s;
for (int i = 0; i < n; i++)
{
s.insert ({a[i] , i});
q[a[i]].push(i);
}
for (int j = 0; j < Q; j++)
{
s.erase({a[X[j]] , X[j]});
a[X[j]] = V[j];
s.insert({a[X[j]] , X[j]});
q[a[X[j]]].push(X[j]);
for (int val = 1; val <= 100; val++)
{
while (q[val].size() && a[q[val].top()] != val) q[val].pop();
if (q[val].size())
{
answer[j] = max(answer[j] , q[val].top() - (int)s.order_of_key({val, q[val].top()}));
}
}
}
return answer;
}
# | 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... |