# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
408758 | 2021-05-19T15:23:17 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 <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; }