-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABC337F.cpp
More file actions
32 lines (32 loc) · 803 Bytes
/
ABC337F.cpp
File metadata and controls
32 lines (32 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/extc++.h>
using namespace std;
namespace pbds = __gnu_pbds;
using ui = unsigned int;
using uli = unsigned long long int;
using li = long long int;
int main(void) {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
size_t n, m;
ui k;
cin >> n >> m >> k;
list<size_t> a(n);
vector<ui> t(n);
for (size_t& i : a) cin >> i, ++t[--i];
for (ui& i : t) i = min(i, k);
ui ans = 0, enb = 0;
list<size_t>::iterator jt = a.begin();
vector<ui> cnt(n);
for (size_t i = 0; i < n; ++i) {
while (jt != a.end() && enb < m) {
if (cnt[*jt]++ == 0) {
++enb;
ans += t[*jt];
}
++jt;
}
cout << ans << '\n';
if (--cnt[a.front()] == 0) --enb, ans -= t[a.front()];
a.push_back(a.front()), a.pop_front();
}
return 0;
}