uva 10131】的更多相关文章

option=com_onlinejudge&Itemid=8&page=show_problem&problem=1072">链接:UVa 10131 题意:给定若干大象的体重及智商值.求满足大象体重严格递增,智商严格递减的序列的最大个数. 并打印随意一组取得最大值的序列的大象编号 分析:这个是LIS的应用,仅仅只是推断条件有两个,能够先对大象的体重排序,可是要打印路径. 那就必须得回溯求路径.能够直接逆序循环求,当然递归也是一个好的选择 #include<…
题目连接:10131 - Is Bigger Smarter? 题目大意:给出n只大象的属性, 包括重量w, 智商s, 现在要求找到一个连续的序列, 要求每只大象的重量比前一只的大, 智商却要小, 输出最长值和方案, 方案不唯一的时候任意输出一种. 解题思路:DAG无定点的最长路问题, 记忆化搜索,并记录当前最有解的前驱. #include <stdio.h> #include <string.h> const int N = 10005; struct State { int w…
DP 先对大象体重排序   然后寻找智力的最长升序子列  输出路径.... #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #define inf 0x7fffffff using namespace std; typedef struct { int w,s,num; } elem; bool cmp(elem a, elem b) { return…
题目链接 题意:有好多行,每行两个数字,代表大象的体重和智商,求大象体重越来越大,智商越来越低的最长序列,并输出. 思路:先排一下序,再按照最长上升子序列计算就行. 还有注意输入, 刚开始我是这样输入的   cnt = 1; while(~scanf("%d%d", &p[cnt].w, &p[cnt++].s)) 结果p[1].w的值没有,为0, 所以注意在连续输入的时候不能用 cnt++; #include <iostream> #include <…
Is Bigger Smarter? The Problem Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as possible into a sequence so that th…
Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as possible into a sequence so that the weights are increasing, but t…
动态规划题.类似UVa103 Stacking Box,都是题目给一种判断嵌套的方法然后求最长序列.提前对数据排序可以节省一些时间开销. 我的解题代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; #define MAXN 1005 int N; int…
第一次写动态规划的代码,整了一天,终于AC. 题目: Question 1: Is Bigger Smarter? The Problem Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data…
Description   Question 1: Is Bigger Smarter? The Problem Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as possible…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5…