poj1083
来源:互联网 发布:淘宝做代理发货怎么办 编辑:程序博客网 时间:2024/05/22 06:17
//poj1083 想了很多,尤其是贪心算法,结果很多情况,一直想用递归贪心解决。最后失败。//失败的数据集: 10 100, 50 120, 130 200, 110 135, 121 124,结果是20//最后采用小优的方法 全部放到同一栏中,只要输出最大重复的走廊次数就可以。#include <iostream>#include <algorithm>using namespace std;int s[205], t[205];int room[401];int main(){int n;cin>>n;while(n--){memset(s, 0, sizeof(s));memset(t, 0, sizeof(t));memset(room, 0, sizeof(room));int f;cin>>f;for(int i = 0; i < f; i++){cin>>s[i]>>t[i];if(s[i] > t[i]){int temp = s[i];s[i] = t[i];t[i] = temp;}if(s[i] % 2 != 0)s[i]++;if(t[i] % 2 != 0)t[i]++;for(int j = s[i]; j <= t[i]; j++){room[j]++;}}sort(room, room + 401);cout<<room[400] * 10 <<endl;}return 0;}
0 0
- POJ1083
- poj1083
- poj1083
- poj1083
- POJ1083
- poj1083
- poj1083
- poj1083
- poj1083
- poj1083
- poj1083
- poj1083
- poj1083
- POJ1083
- POJ1083
- poj1083
- poj1083
- POJ1083
- Mysql分页之limit用法与limit优化
- 软工文档总结
- poj2739
- 滑动改变ViewPager背景颜色
- android主题和样式
- poj1083
- 最小生成树-Prim算法和Kruskal算法
- poj2262
- js深入学习专题 ------ 类数组的对象和数组对象的区别和联系
- poj1503
- 汉诺塔
- 恒天然恒天然
- java 回调函数
- 实现分页总结