# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
408759 | 2021-05-19T15:24:22 Z | gg123_pe | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 0 ms | 0 KB |
#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 <ll> 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; }