문제 링크: https://www.acmicpc.net/problem/11972
11972번: Contaminated Milk
Farmer John, known far and wide for the quality of the milk produced on his farm, is hosting a milk-tasting party for \(N\) of his best friends (\(1 \leq N \leq 50\)). Unfortunately, of the \(M\) types of milk featured at the party (\(1 \leq M \leq 50\)),
www.acmicpc.net
먼저 상했을 가능성이 있는 우유들을 찾은 다음, 그 우유를 마신 사람수의 최대값이 답.
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
|
#include <bits/stdc++.h>
using namespace std;
struct info {
int p, m, t;
};
int N, M, D, S;
int milk[51], candidate[51];
info data[1001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N >> M >> D >> S;
for(int i = 0; i < D; i++)
cin >> data[i].p >> data[i].m >> data[i].t;
for(int i = 0; i < S; i++) {
int person, time;
cin >> person >> time;
// 상한 우유일 가능성이 있는 우유를 걸러냄.
for(int j = 0; j < D; j++) {
if(data[j].p == person && data[j].t < time)
milk[data[j].m]++;
}
}
int ans = 0;
for(int i = 1; i <= 50; i++) {
if(milk[i] >= S) { // 상한 우유일때
memset(candidate, 0, sizeof(candidate));
int cnt = 0;
for(int j = 0; j < D; j++) {
if(data[j].m == i && candidate[data[j].p] == 0){
candidate[data[j].p] = 1;
cnt++;
}
}
ans = max(ans, cnt);
}
}
cout << ans << '\n';
return 0;
}
|
'USACO > Bronze' 카테고리의 다른 글
백준 11978 Mowing the Field (USACO January 2016 Bronze 3번) (0) | 2020.02.27 |
---|---|
백준 11977 Angry Cows (USACO January 2016 Bronze 2번) (0) | 2020.02.27 |
백준 11976 Promotion Counting (USACO January 2016 Bronze 1번) (0) | 2020.02.26 |
백준 11971 속도 위반 (USACO December 2015 Bronze 2번) (0) | 2020.02.26 |
백준 11970 Fence Painting (USACO December 2015 Bronze 1번) (0) | 2020.02.26 |