# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106268 | 2024-10-29T17:15:52 Z | vladilius | Painting Walls (APIO20_paint) | C++17 | 0 ms | 0 KB |
#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; } };