문제 링크: https://www.acmicpc.net/problem/15593
15593번: Lifeguards (Bronze)
The first line of input contains $N$ ($1 \leq N \leq 100$). Each of the next $N$ lines describes a lifeguard in terms of two integers in the range $0 \ldots 1000$, giving the starting and ending point of a lifeguard's shift. All such endpoints are distinct
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
|
#include <bits/stdc++.h>
using namespace std;
int N, s[101], e[101], t[1001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N;
for(int i = 0; i < N; i++) {
cin >> s[i] >> e[i];
for(int j = s[i]; j < e[i]; j++) t[j]++;
}
int ans = 0;
for(int i = 0; i < N; i++) {
for(int j = s[i]; j < e[i]; j++)
t[j]--;
int cnt = 0;
for(int j = 0; j <= 1000; j++)
if(t[j]) cnt++;
ans = max(ans, cnt);
for(int j = s[i]; j < e[i]; j++)
t[j]++;
}
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 15751 Teleportation (USACO February 2018 Bronze 1번) (0) | 2020.03.07 |
---|---|
백준 15594 Out of Place (USACO January 2018 Bronze 3번) (0) | 2020.03.06 |
백준 15592 Blocked Billboard II (USACO January 2018 Bronze 1번) (0) | 2020.03.06 |
백준 15464 The Bovine Shuffle (USACO December 2017 Bronze 2번) (0) | 2020.03.03 |
백준 15463 Blocked Billboard (USACO December 2017 Bronze 1번) (0) | 2020.03.03 |