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;
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 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... |