문제 링크: https://www.acmicpc.net/problem/11977
11977번: Angry Cows (Bronze)
In this example, launching a cow onto the hay bale at position 5 will cause the bales at positions 4 and 6 to explode, each with blast radius 2. These explosions in turn cause the bales at positions 3 and 8 to explode, each with blast radius 3. However, th
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;
int n, x[101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) cin >> x[i];
sort(x, x + n);
int ans = 0;
for(int i = 0; i < n; i++) {
int rad = 1, cnt = 1;
int cur = i;
int l = cur - 1;
while(1) {
if(l < 0 || x[cur] - x[l] > rad) break;
while(l >= 0 && x[cur] - x[l] <= rad) {
cnt++;
l--;
}
cur = l + 1;
rad++;
}
rad = 1;
cur = i;
int r = cur + 1;
while(1) {
if(r >= n || x[r] - x[cur] > rad) break;
while(r < n && x[r] - x[cur] <= rad) {
cnt++;
r++;
}
cur = r - 1;
rad++;
}
ans = max(ans, cnt);
}
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 11999 Milk Pails (USACO February 2016 Bronze 1번) (0) | 2020.02.27 |
---|---|
백준 11978 Mowing the Field (USACO January 2016 Bronze 3번) (0) | 2020.02.27 |
백준 11976 Promotion Counting (USACO January 2016 Bronze 1번) (0) | 2020.02.26 |
백준 11972 Contaminated Milk (USACO December 2015 Bronze 3번) (0) | 2020.02.26 |
백준 11971 속도 위반 (USACO December 2015 Bronze 2번) (0) | 2020.02.26 |