#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define mp make_pair
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define Task ""
using namespace std;
template <typename T > inline void MIN(T &a, T b) { if(a>b) a=b; }
template <typename T > inline void MAX(T &a, T b) { if(a<b) a=b; }
const int N=8005;
int n, Q, t[N], L;
vector <int > v, ans, a, id, val;
int get(int id) {
int ret=0;
while(id<=L) {
ret+=t[id];
id+=id&(-id);
}
return ret;
}
void update(int id) {
while(id) {
++t[id];
id-=id&(-id);
}
}
vector <int > countScans(vector <int > a, vector <int > id, vector <int > val) {
vector <int > ret(Q, 0);
rep(j, 1, Q) {
a[id[j]+1]=val[j];
v.clear();
v.resize(n+1, 0);
rep(i, 1, n) v[i]=a[i];
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end())-v.begin());
L=v.size();
rep(i, 1, L) t[i]=0;
int mx=0;
rep(i, 1, n) {
int r=upper_bound(v.begin(), v.end(), a[i])-v.begin();
MAX(mx, get(r+1));
update(r);
}
ret[j-1]=mx;
}
return ret;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(Task".inp", "r", stdin);
//freopen(Task".out", "w", stdout);
cin >> n >> Q;
a.resize(n+1);
id.resize(n+1);
val.resize(n+1);
rep(i, 1, n) cin >> a[i];
rep(i, 1, Q) cin >> id[i] >> val[i];
ans=countScans(a, id, val);
for(int xx:ans) cout << xx << '\n';
return 0;
}
Compilation message
/tmp/ccS2eukL.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccvmurmc.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status