USACO 2016 February Contest, Silver Problem 2. Load Balancing
来源:互联网 发布:蒋勤勤的长相知乎 编辑:程序博客网 时间:2024/06/06 01:34
#include<algorithm>
#include<fstream>
#include<iostream>
using namespace std;
const int maxn = 1010;
const int inf = 0x7fffffff;
struct Tnode {
int x, y;
bool operator <(const Tnode s)const {
return this->x < s.x;
}
} pos[maxn];
ifstream fin("balancing.in");
ofstream fout("balancing.out");
int n;
int main() {
fin >> n;
for(int i = 0; i != n; ++i)fin >> pos[i].x >> pos[i].y;
sort(pos, pos + n);
int ans = n;
for(int i = 0; i != n; ++i) {
Tnode low[maxn], high[maxn];
int lowCnt = 0, highCnt = 0;
for(int j = 0; j != n; ++j)
if(pos[j].y <= pos[i].y)low[lowCnt++] = pos[j];
else high[highCnt++] = pos[j];
int lowI = 0, highI = 0;
while(lowI < lowCnt || highI < highCnt) {
int nowX = inf;
if(lowI != lowCnt)nowX = min(nowX, low[lowI].x);
if(highI != highCnt)nowX = min(nowX, high[highI].x);
for(; lowI != lowCnt && low[lowI].x == nowX; ++lowI);
for(; highI != highCnt && high[highI].x == nowX; ++highI);
ans = min(ans, max(max(lowI, lowCnt - lowI), max(highI, highCnt - highI)));
}
}
fout << ans << endl;
return 0;
}
- USACO 2016 February Contest, Silver Problem 2. Load Balancing
- USACO 2016 February Contest, Bronze Problem 3. Load Balancing
- 【C++心路历程33】【USACO 2016 February Contest, Bronze Problem 3.】 Load Balancing(加难)
- USACO 2016 February Contest, Silver Problem 3. Milk Pails
- USACO 2014 February Contest, Silver
- USACO 2017 February Contest Silver
- USACO 2016 February Contest, Bronze Problem 2. Circular Barn
- USACO 2016 FEBRUARY CONTEST, BRONZE PROBLEM 1. MILK PAILS
- USACO 2015 February CONTEST,Silver&Gold Division Solution
- USACO 2016 December Contest, Silver A
- 【USACO 2007 February Silver】农场派对
- 【DP】[USACO 2016 February Contest, Gold]Circular Barn Revisited
- 【最小生成树】[USACO 2016 February Contest, Gold]Fenced In
- 【poj 3268】 Silver Cow Party 【USACO 2007 February Silver】
- USACO 2012 February Contest, Bronze Division
- USACO 2012 March Contest, Silver Division
- USACO 2012 January Contest, Silver Division Solution
- 【贪心】[USACO 2015 February Contest, Gold]Circular Barn
- USACO 2016 FEBRUARY CONTEST, BRONZE PROBLEM 1. MILK PAILS
- 环信:发送头像和昵称(从消息扩展中获取)
- USACO 2016 February Contest, Bronze Problem 2. Circular Barn
- USACO 2016 February Contest, Bronze Problem 3. Load Balancing
- JavaScript求链表的环大小
- USACO 2016 February Contest, Silver Problem 2. Load Balancing
- USACO 2016 February Contest, Silver Problem 3. Milk Pails
- java积累——数据库手动控制事务工具类
- usaco2016open bronze1 diamond
- usaco2016open bronze3 reduce
- usaco2016open silver1 reduce
- usaco2016open silver2 diamond
- Linux改变进程优先级 linux Nice命令
- 集训第二周小结(4.17~4.23)