# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
408798 | gg123_pe | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 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>
#include "bubblesort2.h"
using namespace std;
typedef vector<long long> vl;
typedef long long ll;
#define f(i,a,b) for(ll i=a ; i<b ; i++)
vl countScans(vl A, vl X, vl V){
int q = X.size(), n = A.size();
vl ans, v;
f(i,0,q){
v.clear();
ll mini = 1e9+5, aux = 0;
f(i,0,n)
mini = min(mini,A[i]);
f(i,0,n){
if(A[i] == mini)
v.push_back(i);
}
ll l = v.size();
f(i,0,l)
aux = max(aux,abs(v[i]-i));
ans.push_back(aux);
}
return ans;
}
int main(){
ll N, Q, a1, x1, v1;
vl A, X, V;
cin >> N >> Q;
f(i,0,N) {
cin >> a1;
A.push_back(a1);
}
f(i,0,Q){
cin >> x1 >> v1;
X.push_back(x1); V.push_back(v1);
}
countScans(A, X, V);
return 0;
}