POJ 1083 线性DP
来源:互联网 发布:java 泛型 多继承 编辑:程序博客网 时间:2024/06/05 20:01
题意:在一条走廊的两侧各有200个房间,现在给定一些成对的房间相互交换桌子,但是走廊每次只能通过一组搬运, 也就是说如果两个搬运过程有交叉是不能同时搬运的,要依次来,一次搬运10min,问完成所有的搬运的最少用时。
思路:考虑每个房间有多少搬运过程需要经过,我们截取最大的房间经过的次数就可以了,挺锻炼思维的一道题。
代码:
代码:
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>using namespace std;const int maxn = 405;int T, N, ans;int room[maxn];int main(){ cin >> T; while (T--) { cin >> N; ans = 0; memset(room, 0, sizeof(room)); for (int i = 1; i <= N; ++i) { int x, y; scanf("%d%d", &x, &y); if (x > y) swap(x, y); if(x%2==0) x--; if(y%2==1) y++; for(int j = x; j <= y; ++j) { room[j]++; ans = max(ans, room[j]); } } cout << ans * 10 << endl; }}
0 0
- POJ 1083 线性DP
- poj 3666 线性dp
- POJ 2385 线性DP
- POJ 2479 初步线性 DP
- POJ 1745 Divisibility (线性dp)
- POJ 1260 Pearls(线性dp)
- poj-3783-Balls dp/线性dp
- POJ - 2479 《Maximum sum》 【线性DP】
- POJ 2355 Railway tickets (线性dp)
- POJ 1925 Spiderman(线性dp)
- POJ 2479 - Maximum sum(线性DP)
- POJ 2479-Maximum sum(线性dp)
- POJ 1948 Triangular Pastures (线性dp)
- POJ 3783 Balls (线性dp 智力题)
- POJ 1163 The Triangle (线性dp)
- poj 1088 滑雪(线性DP)
- POJ-2346 Lucky tickets(线性DP)
- POJ 2385 Apple Catching(线性DP)
- TOP10_SQL
- 十二、Springboot的静态资源处理
- java.lang.NoClassDefFoundError和ClassNotfoundException
- gulp详细入门教程
- 使用Java开发高性能网站需要关注的那些事儿
- POJ 1083 线性DP
- 标题:素数等差数列
- 动态规划练习一 19题
- springmvc Controller中 自动完成 对象转json
- day68_oracle
- git学习记录
- git提交到开源中国代码托管问题
- springmvc之JSR303数据校验
- 回文数字(dfs)