문제 링크: https://www.acmicpc.net/problem/12001
12001번: Load Balancing (Bronze)
Farmer John's \(N\) cows are each standing at distinct locations \((x_1, y_1) \ldots (x_n, y_n)\) on his two-dimensional farm (\(1 \leq N \leq 100\), and the \(x_i\)'s and \(y_i\)'s are positive odd integers of size at most \(B\)). FJ wants to partition hi
www.acmicpc.net
N개 점들의 x좌표, y좌표들 사이에 가능한 모든곳에 fence를 놓고, 나뉘어진 4개 각각 region에 있는 점들의 수의 maximum인 M 을 찾고, 그 M값들의 최소값을 찾음. 시간 복잡도는 O(N^3)이고, N의 최대값이 100이기에 충분히 빠른시간내에 돌아감.
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
|
#include <bits/stdc++.h>
using namespace std;
int N, B;
vector<pair<int, int>> pos;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N >> B;
for(int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
pos.push_back({x, y});
}
int ans = 1e9;
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
int a = pos[i].first + 1, b = pos[j].second + 1;
int cnt[4] ={};
for(int k = 0; k < N; k++) {
int x = pos[k].first, y = pos[k].second;
if(x > a && y > b) cnt[0]++;
else if(x < a && y > b) cnt[1]++;
else if(x > a && y < b) cnt[2]++;
else cnt[3]++;
}
int M = 0;
for(int k = 0; k < 4; k++)
M = max(M, cnt[k]);
ans = min(ans, M);
}
}
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 14173 Square Pasture (USACO December 2016 Bronze 1번) (0) | 2020.02.28 |
---|---|
백준 12005 Diamond Collector (USACO US Open 2016 Bronze 1번) (0) | 2020.02.27 |
백준 12000 Circular Barn (USACO February 2016 Bronze 2번) (0) | 2020.02.27 |
백준 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 |