USACO/Bronze
백준 16770 The Bucket List (USACO December 2018 Bronze 2번)
ssam..
2020. 3. 13. 09:51
문제 링크: https://www.acmicpc.net/problem/16770
16770번: The Bucket List
In this example, FJ needs 4 buckets: He uses buckets 1 and 2 for milking cow 3 (starting at time 2). He uses bucket 3 for milking cow 1 (starting at time 4). When cow 2 arrives at time 8, buckets 1 and 2 are now available, but not bucket 3, so he uses buck
www.acmicpc.net
각 소마다의 time interval에 필요한 bucket수를 t 배열에 더해주고 나서, 최대값을 구하면 됨.
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
|
#include <bits/stdc++.h>
using namespace std;
int n, t[1001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) {
int s, e, b;
cin >> s >> e >> b;
for(int j = s; j <= e; j++)
t[j] += b;
}
int ans = 0;
for(int i = 1; i <= 1000; i++)
ans = max(ans, t[i]);
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|