HDU 1050(贪心)
来源:互联网 发布:怎么淘宝联盟不能注册 编辑:程序博客网 时间:2024/06/07 10:14
题意:有一个走廊,走廊上下都有一排房间,从一个房间移动桌子到另一个房间要花费10分钟,走廊只够一个桌子移动,如果路径不重叠,则可以同时移动,求要花费的时间。
#include <cstdio>#include <cstdlib>int main(){ int T, n; int a, b, c[200]; int i, j, temp, max; scanf("%d", &T); while (T--) { for (i = 0; i < 200; ++i) c[i] = 0; scanf("%d", &n); for (i = 1; i <= n; ++i) { scanf("%d %d", &a, &b); a = (a-1)/2; b = (b-1)/2; if (a > b) a ^= b ^= a ^= b; for (j = a; j <= b; ++j) ++c[j]; } max = 0; for (i = 1; i < 200; ++i) if (c[i] > max) max = c[i]; printf("%d\n", max * 10); }}
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;struct Table{ int s, t, v; bool operator <(const Table& rhs) const { return s < rhs.s; }} table[200];int main(){ int T, n, a, b, N, sum, i; while (scanf("%d", &T) != EOF) { while (T--) { scanf("%d", &n); N = n; sum = 0; while (n--) { scanf("%d%d", &a, &b); a = (a-1)/2, b = (b-1)/2; if (a > b) a ^= b ^= a ^= b; table[n].s = a, table[n].t = b, table[n].v = 0; } sort(table, table + N); int have_visit = 0; while (have_visit < N) { int first_no_visit = -1; for (i = 0; i < N; ++i) if (table[i].v == 0) { ++have_visit; first_no_visit = i; table[i].v = 1; break; } while (++i < N) { if (table[i].v == 0 && table[i].s > table[first_no_visit].t) { ++have_visit; table[i].v = 1; first_no_visit = i; } } ++sum; } printf("%d\n", 10 * sum); } } return 0;}
0 0
- HDU 1050(贪心)
- hdu 1050(贪心算法)
- hdu 1050_贪心
- HDU ACM 1050 贪心
- hdu 1050 贪心
- HDU 1050(贪心)
- 贪心专题 HDU 1050
- hdu 1050 Moving Tables (贪心)
- hdu 1050 moving tables 贪心
- hdu 1050 Moving Tables (贪心)
- hdu 1050 Moving Tables_贪心
- HDU 1050 Moving Tables 贪心
- HDU--1050:Moving Tables (贪心)
- hdu 1050 Moving Tables(贪心)
- HDU-1050 Moving Tables 贪心
- HDU 1050 Moving Tables 贪心!!
- HDU 1050 Moving Tables (贪心)
- 贪心2 HDU - 1050 题解
- Log4j使用相对路径指定log文件及使用总结
- Spring 的事务处理
- UITableViewCell的标记、移动、删除、插入
- Windows CE下USB摄像头驱动开发(以OV511为例,附带全部源代码以及讲解) [转]
- LA3905
- HDU 1050(贪心)
- Opencv2系列学习笔记12(检测fast特征)
- 分布式日志收集系统Apache Flume的设计介绍
- Storm集群安装部署步骤【详细版】
- 指针常量与常量指针区别
- 传智学习日志篇:六
- 实现从内存中解压JPEG
- Scrapy UnicodeDecodeError解决方法
- Ecava Sdn Bhd IntegraXor产品项目信息泄露漏洞