uva 11776 - Oh Your Royal Greediness!(暴力)
来源:互联网 发布:国家药监局数据查询网 编辑:程序博客网 时间:2024/04/27 14:47
题目链接:11776 - Oh Your Royal Greediness!
题目大意:有n农民,给出每个农民的工作的起始时间和终止时间。然后每个农民在工作的时候都必须有一个监工,问最少需要几个监工。
解题思路:一开始以为是区间选点问题,后来WA了。然后直接暴力就过了。以每个农民的结束时间为标准,若其他人的起始时间小于这个标准,并且终止时间大于这个标准,监工数就要加+1,然后从中选出最大值。
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int N = 1005;int n;struct state {int x, y;}s[N];bool cmp(const state& a, const state& b) {return a.x < b.x;}void init() {for (int i = 0; i < n; i++) scanf("%d %d", &s[i].x, &s[i].y);sort(s, s + n, cmp);}int solve() {int ans = 0;for (int i = 0; i < n; i++) {int cnt = 0;for (int j = 0; j < n; j++) {if (s[j].x > s[i].y) break; if (s[j].x <= s[i].y && s[j].y >= s[i].y) cnt++;}ans = max(ans, cnt);}return ans;}int main() {int cas = 1;while (scanf("%d", &n) == 1 && n != -1) {init();printf("Case %d: %d\n", cas++, solve());}return 0;}
1 0
- uva 11776 - Oh Your Royal Greediness!(暴力)
- Oh Your Royal Greediness! UVA
- UVa 11776 - Oh Your Royal Greediness! (贪心 + 模拟)
- UVa11776 - Oh Your Royal Greediness!
- 11776 - Oh Your Royal Greediness!(最大重叠区间)
- UVA 10340 )(暴力)
- UVa 140 - BandWidth (暴力)
- uva 10277 (概率论 + 暴力)
- UVA - 818(暴力+分析)
- UVa 585 Triangles(暴力)
- UVa 140:Bandwidth(暴力)
- UVa 1587 Box(暴力)
- Uva 725 Division(暴力)
- UVA 201 Squares(暴力)
- uva 11210 Chinese Mahjong(暴力搜索)
- UVA 757 Gone Fishing(贪心 + 暴力)
- uva 270 Lining Up(暴力+ 几何)
- UVA 12649 Folding Machine(暴力搜索)
- ORA-1555经典的错误
- 浅谈C中的malloc和free “来自bccn C语言论坛”
- SQL server 2005 附加数据库出错解决方法
- 【KVM】SR-IOV PCI-hotplug VT-d技术
- ASM AAM能用来做什么
- uva 11776 - Oh Your Royal Greediness!(暴力)
- AAM(Active Appreance Model)算法用于人脸识别总结
- 个人工作技术感想
- [Project Euler]Problem 1:Multiples of 3 and 5
- 黑马程序员--十二、Java反射
- 装饰模式---衣服穿着设计(C++实现)
- 黑马程序员_多态
- 谷歌分析iOS开发包实战
- Day2解题报告