hdu1087 LIS变形
来源:互联网 发布:淘宝的消费总额怎么看 编辑:程序博客网 时间:2024/06/07 18:25
/************************************************ *Author :jibancanyang *Created Time :日 4/ 3 21:23:36 2016 *File Name :hdu1087.cpp *题目类型: LIS变形 *很简单的题,但是开始没有把转移方程想好就写,导致了浪费时间... *定义:dp[i]为以i结尾的最好路径的最大值,然后由它前面的数转移过来就好了.*************************************************/#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <stack>using namespace std;typedef pair<int, int> pii;typedef long long ll;typedef unsigned long long ull;vector<int> vi;#define xx first#define yy second#define sa(n) scanf("%d", &(n))#define rep(i, a, n) for (int i = a; i < n; i++)#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++) #define pr(x) cout << #x << ": " << x << " "#define prln(x) cout << #x << ": " << x << endlconst int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;int a[maxn / 100];ll dp[maxn / 100];int n;int main(void){#ifdef LOCAL //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);#endif // cin.sync_with_stdio(false); while (sa(n), n) { rep (i, 0, n) { sa(a[i]), dp[i] = 0; } dp[0] = a[0]; rep (i, 1, n) { for (int j = i - 1; j >= 0; j--) { dp[i] = max(dp[i], a[i] > a[j] ? dp[j] + a[i] : a[i]); } } ll ans = 0; rep (i, 0, n) { ans = max(ans, dp[i]); } cout << ans << endl; } return 0;}
0 0
- hdu1087 LIS变形
- LIS-hdu1087
- hdu1087 动态规划入门LIS
- HDU1087 Super Jumping! Jumping! Jumping!(LIS)
- hdu1087 Super Jumping! Jumping! Jumping!(LIS)
- HDU1087 最简单的lis动态规划
- hdu_1069 LIS变形
- hdu1069 LIS 变形
- hdu 5087(LIS变形)
- hdu 5734 LIS变形
- HDU5256 LIS变形
- hdu 5256 LIS变形
- HDU5087 Revenge of LIS II (LIS变形)
- HDU5141 - LIS again(LIS的变形)
- HDU 5141 LIS Again LIS变形+BIT
- hdu1087
- hdu1087
- HDU1087
- iOS 字体转换
- Myeclipse 导入别人的项目,汉字是乱码怎么办?
- 无处不在的二分查找
- 什么是ANR 如何避免它?
- 二叉树的遍历
- hdu1087 LIS变形
- 快速熟悉项目代码
- 对于MathType中公式与文字错位的问题怎么解决
- Spring源代码解析(三):Spring JDBC
- C#更改groupbox边框颜色
- 3.7.5 event_loop:事件循环
- 64位win7系统中JDK的安装及环境变量的配置
- Android Studio常用插件
- Linux下undefined reference to ‘pthread_create’问题解决