UVA
来源:互联网 发布:乐乎城市青年社区投诉 编辑:程序博客网 时间:2024/06/07 22:28
详见 HDU - 1160 FatMouse’s Speed
#include<iostream>#include<stdio.h>#include<algorithm>#include<cmath>#include<string.h>#define max(a,b) ((a)>(b)?(a):(b))#define min(a,b) ((a)<(b)?(a):(b))const int INF = 0x3f3f3f3f;const int NINF = -INF -1;const int MAXN = 10000+10;using namespace std;struct point { int w, s, id;};point p[MAXN];int dp[MAXN], path[MAXN];int n, ans;bool cmp(point a, point b) { if (a.w != b.w) return a.w < b.w; return a.s > b.s;}void print_ans(int i, int cnt) { if (cnt == dp[ans]) return; print_ans(path[i], cnt+1); printf("%d\n", p[i].id+1);}int main() { n = 0; while (scanf("%d%d", &p[n].w, &p[n].s) != EOF) { n++; p[n].id = n; } sort(p, p+n, cmp); ans = 0; for (int i = 0; i < n; i++) { dp[i] = 1; path[i] = i; for (int j = 0; j < i; j++) if (p[i].w > p[j].w && p[i].s < p[j].s && dp[i] < dp[j]+1) { dp[i] = dp[j]+1; path[i] = j; } if (dp[ans] < dp[i]) ans = i; } printf("%d\n", dp[ans]); print_ans(ans, 0); return 0;}
阅读全文
0 0
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- 抽象类和接口的特性的一些记忆技巧
- Cesium粒子系统详述
- [BZOJ4710]4710: [Jsoi2011]分特产 容斥原理+组合数学
- HDU
- maven profile不生效解决办法,加上下面插件
- UVA
- 阿里云CentOS7.2系统JavaWeb开发环境搭建
- 整理一下 PagerSlidingTabStrip
- RK3288开发板PopMetal上的GPIO驱动实例
- 判断多选框是否被选中
- 强制文件下载header设置
- linux OSI七层模型、TCP-IP协议栈及每层结构大揭秘
- POJ 3281 Dining(网络流建模)
- PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)