forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2531.cpp
More file actions
48 lines (39 loc) · 989 Bytes
/
2531.cpp
File metadata and controls
48 lines (39 loc) · 989 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Authored by : unluckyjung
// Co-authored by : -
// http://boj.kr/9a310c28f35f4ecab441c986fe684050
#include <bits/stdc++.h>
using namespace std;
int dishesCount, sushiKindCount, chainingEatCount, couponNum;
int dishes[30001 * 2];
int ateCount[3001];
int ateKindCount;
int answer;
void eat(int sushi) {
if (ateCount[sushi] == 0) {
ateKindCount++;
answer = max(answer, ateKindCount);
}
ateCount[sushi]++;
}
void overeat(int sushi) {
ateCount[sushi]--;
if (ateCount[sushi] == 0) ateKindCount--;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> dishesCount >> sushiKindCount >> chainingEatCount >> couponNum;
ateCount[couponNum]++;
ateKindCount = 1;
answer = 1;
for (int i = 0; i < dishesCount; ++i) {
cin >> dishes[i];
dishes[dishesCount + i] = dishes[i];
}
for (int i = 0; i < dishesCount * 2; ++i) {
if (i >= chainingEatCount) overeat(dishes[i - chainingEatCount]);
eat(dishes[i]);
}
cout << answer;
return 0;
}