# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
408758 | 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>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(ll i=a ; i<b ; i++)
//A
ll n, q, l, x, vi;
ll a[2005];
vector <int> v;
int solve(){
v.clear();
ll mini = 1e9+5, ans = 0;
f(i,0,n)
mini = min(mini,a[i]);
f(i,0,n){
if(a[i] == mini)
v.push_back(i);
}
l = v.size();
f(i,0,l)
ans = max(ans,abs(v[i]-i));
return ans;
}
int main(){
cin >> n >> q;
f(i,0,n) cin >> a[i];
while(q--){
cin >> x >> vi;
a[x] = vi;
cout << solve() << '\n';
}
return 0;
}