# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106268 | vladilius | Painting Walls (APIO20_paint) | C++17 | 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;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
const int inf = 3e5;
struct DS{
vector<int> a, f;
int n, mx;
DS(int ns){
n = ns;
a.resize(n + 1);
f.resize(n + 1);
f[0] = n;
mx = 0;
}
void upd(int p, int x){
p++;
if (x == 1){
f[a[p]]--;
a[p]++;
f[a[p]]++;
mx = max(mx, a[p]);
}
else {
if (a[p] == mx && f[a[p]] == 1) mx--;
f[a[p]]--;
a[p]--;
f[a[p]]++;
}
}
int get(){
return mx;
}
};