Uva 11078 简单dp
题目链接:http://uva.onlinejudge.org/external/110/11078.pdf
a[i] - a[j] 的最大值。
这个题目马毅问了我,O(n^2)超时,记忆化一下当前最大值。
#include <bits/stdc++.h> using namespace std; int A[],n; int main()
{
int t;
cin>>t;
while(t--) {
cin>>n;
for(int i=;i<n;i++) {
cin>>A[i];
}
int ans = -0x3f3f3f3f;
int maxai = A[];
for(int i=;i<n;i++) {
ans = max(ans,maxai-A[i]);
maxai = max(maxai,A[i]);
} cout<<ans<<endl;
}
return ;
}
Uva 11078 简单dp的更多相关文章
- uva 10648(简单dp)
Recently one of my friend Tarik became a member of the food committee of an ACM regional competition ...
- Partitioning by Palindromes UVA - 11584 简单dp
题目:题目链接 思路:预处理出l到r为回文串的子串,然后如果j到i为回文串,dp[i] = min(dp[i], dp[j] + 1) AC代码: #include <iostream> ...
- UVA 111 简单DP 但是有坑
题目传送门:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18201 其实是一道不算难的DP,但是搞了好久,才发现原来是题目没 ...
- UVA - 11584 划分字符串的回文串子串; 简单dp
/** 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34398 UVA - 11584 划分字符串的回文串子串: 简单 ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Codeforces Round #260 (Div. 1) A. Boredom (简单dp)
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...
- codeforces Gym 100500H A. Potion of Immortality 简单DP
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...
- 简单dp --- HDU1248寒冰王座
题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...
- poj2385 简单DP
J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bit ...
随机推荐
- appium ios 真机自动化环境搭建
近期由于工作需要,本小菜在弄appium+ios+iphone真机的移动自动化,在网上找寻各种资料,发现针对IOS方面的资料少之又少,公司其它部门的弄过的同事也寥寥无几,即使有,也是安卓方面的.本次书 ...
- Java 类型转换(int->String)
1 如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或 i = Integer.parseInt([ ...
- vue懒加载 路由 router 的编写(resolve)
如果用import引入的话,当项目打包时路由里的所有component都会打包在一个js中,造成进入首页时,需要加载的内容过多,时间相对比较长.当你用require这种方式引入的时候,会将你的comp ...
- my.宝石 --- --- ZC 收集
1. DT PT 头盔 太阳石 物理伤害+8 √ 月亮石 物理防御+12 √ 武器 太阳石 物理伤害+8 √ 舍利子 法术伤害+6 ...
- 关于C语言读取文件时候多读一行
梗概:为什么C语言读取文件到结构体时为什么整天多读一行?一切都是[!feof(fp)]的错!!! while (!feof(fp)) { fgets(buffer, , fp); j++; } 像这样 ...
- [转]jQuery AJAX pagination plugin with ASP.NET Server Side
本文转自:http://do-web.com/jpaging/usage How does it work? 1. In order to implement the plugin, you need ...
- C++(SOCKET)简单爬虫制作
先给出代码:(我使用的是VS编译器,需要在项目->project属性-> #include <iostream> #include <stdio.h> #inclu ...
- 测试阿里云1核2g轻量级服务器的吞吐量
使用jmeter对部署的dbshop发起请求,单线程5000次请求 面板为宝塔界面 吞吐量大概在每秒48个请求左右.可以看出阿里云1核2g服务器其实并不能进行实战,只是新手练手而已. 阿里云另一种ec ...
- 会话状态在此上下文中不可用HttpModule中无法访问Session原因
写了一个自定义HttpModule,但始终访问不了Session,代码如下: public class RouteModule : IHttpModule, System.Web.SessionSta ...
- [Java][Servlet] Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"]
Background: Servlet version 3.1(3.0之后就有了@WebServlet注解) Error 严重: Failed to destroy end point associa ...