题目链接: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的更多相关文章

  1. uva 10648(简单dp)

    Recently one of my friend Tarik became a member of the food committee of an ACM regional competition ...

  2. Partitioning by Palindromes UVA - 11584 简单dp

    题目:题目链接 思路:预处理出l到r为回文串的子串,然后如果j到i为回文串,dp[i] = min(dp[i], dp[j] + 1) AC代码: #include <iostream> ...

  3. UVA 111 简单DP 但是有坑

    题目传送门:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18201 其实是一道不算难的DP,但是搞了好久,才发现原来是题目没 ...

  4. UVA - 11584 划分字符串的回文串子串; 简单dp

    /** 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34398 UVA - 11584 划分字符串的回文串子串: 简单 ...

  5. HDU 1087 简单dp,求递增子序列使和最大

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  6. Codeforces Round #260 (Div. 1) A. Boredom (简单dp)

    题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...

  7. 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 ...

  8. 简单dp --- HDU1248寒冰王座

    题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...

  9. poj2385 简单DP

    J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit ...

随机推荐

  1. Python中的None与 NULL(即空字符)的区别

    None是Python的特殊类型,NoneType对象,它只有一个值None. 它不支持任何运算也没有任何内建方法. None和任何其他的数据类型比较永远返回False. None有自己的数据类型No ...

  2. forEach与map

    一.原生js forEach()和map()遍历 共同点: 1.都是循环遍历数组中的每一项. 2.forEach() 和 map() 里面每一次执行匿名函数都支持3个参数:数组中的当前项item,当前 ...

  3. 关于处理百万级大批量数据的mysql运行几个重要点

    处理大批量百万级的数据几点重要知识点: 一:设置php运行的内存配置 ini_set("memory_limit","1200M"); 在php.ini中有如下 ...

  4. 【ACM】懒省事的小明

    懒省事的小明 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述       小明很想吃果子,正好果园果子熟了.在果园里,小明已经将所有的果子打了下来,而且按果子的不同种 ...

  5. C# 序列化(Binary、Xml、Soap)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  6. Kafka Intro - Configuration

    #Notes: /opt/kafka/config/zookeeper.properties sample # the directory where the snapshot is stored.d ...

  7. CAD安装失败怎样卸载CAD 2019?错误提示某些产品无法安装

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...

  8. [转]分享20佳好玩的 jQuery 游戏

    本文转自:http://www.cnblogs.com/lhb25/archive/2011/04/17/2001089.html jQuery是时下最流行的 JavaScript 库.现在,除了HT ...

  9. 安卓压力测试之monkey

    步骤: 1.把要测试的apk包放在 SDK-platfrom-tools下 2.配置adb.exe的环境变量 3.手机连接上电脑(虚拟机和真机只能连接一个) 4.运行:adb devices   查看 ...

  10. 监听outlook新邮件

    using System; using System.Linq; using Microsoft.Office.Interop.Outlook; using System.Collections.Ge ...