POJ 1083 线性DP
2017-04-17 22:23
344 查看
题意:在一条走廊的两侧各有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; } }
相关文章推荐
- POJ 1458-Common Subsequence(线性dp/LCS)
- POJ 1050 To the Max (简单的线性dp)
- 见微知著----POJ 1159(线性DP问题+滚动数组)
- poj 1083 Moving Tables_dp
- poj 1088 滑雪(线性DP)
- POJ 2479-Maximum sum(线性dp)
- POJ-2346 Lucky tickets(线性DP)
- 线性DP POJ2279 Mr.Young's Picture Permutations
- POJ 2479 - Maximum sum(线性DP)
- POJ-2346 Lucky tickets(线性DP)
- POJ1083【DP】
- [poj 3666] Making the Grade (离散化 线性dp)
- poj 3666 Making the Grade (线性结构上的DP )
- POJ-1088 滑雪 (dfs + 线性dp)
- POJ 1948 Triangular Pastures(双线性dp)
- POJ2479【线性DP】
- POJ 1458-Common Subsequence(线性dp/LCS)
- POJ 1925 Spiderman(线性dp)
- poj 1083 DP
- POJ 2355 Railway tickets (线性dp)