4171.   L-The math problem


Time Limit: 1.0 Seconds   Memory Limit:65536K
Total Runs: 287   Accepted Runs:86


Given an array a with n intergers, please tell me the max(aj−ai),0≤i≤j≤n−1max(aj−ai),0≤i≤j≤n−1.

Input

The input consists of multiple test cases. The first line contains an integer TT, indicating the number of test cases.(1≤T≤1000)(1≤T≤1000)
Each case contains one integer NN.(0≤N≤107)(0≤N≤107). Then comes a line with N intergers ai(−107≤ai≤107)ai(−107≤ai≤107)

Output

For each case only output the answer.

Sample Input

1
5
1 3 5 4 2

Sample Output

4

水题 直接扫一遍 维护最大差值

注意要看清题,j是大于等于i的

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;int a[10000005];int main()
{int t;while(~scanf("%d",&t)){while(t--){memset(a,0,sizeof(a));int n;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d",&a[i]);} int max_dif=0;int minn=999999;for(int i=0;i<n;i++){if(minn>a[i]){minn=a[i];}if(a[i]-minn>max_dif){max_dif=a[i]-minn;}}printf("%d\n",max_dif);}}return 0;
} 

TOJ 4171 L-The math problem(水题)相关推荐

  1. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  2. Poj1207 The 3n + 1 problem(水题(数据)+陷阱)

    一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...

  3. 2015南阳CCPC L - Huatuo's Medicine 水题

    L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous ...

  4. Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题

    C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...

  5. HDU - 1757 A Simple Math Problem(矩阵快速幂,水题)

    题目链接:点击查看 题目大意:实现公式: f(x)=x,x<10 f(x)=a0*f(x-1)+a1*f(x-2)+--+a9*f(x-10) 题目给出a0~a9,一个n和一个m,要求输出f(n ...

  6. A Simple Math Problem 矩阵打水题

    A Simple Math Problem Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x ...

  7. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  8. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  9. NUC1196 Sum【水题+数学题】

    Sum 时间限制: 1000ms 内存限制: 65536KB 通过次数: 1总提交次数: 1 问题描述 Consider the natural numbers from 1 to N. By ass ...

  10. P,MTHBGWB 水题

    今天遇到一道特别恶心的水题,可能是我水平太low,居然用了好久的时间!不过主要是用在看懂题意上了,英文题目好长,好恶心啊!!题目如下: Description Morse code represent ...

最新文章

  1. ISME:中科院微生物所揭示细菌利用光能新机制!
  2. 【转载】rpc.rstatd安装与配置
  3. System tuning中经常用到的一些Tcode
  4. python 通登录银行_Python3 适合初学者学习的银行账户登录系统实例
  5. javase模拟斗地主洗牌和发牌(54)
  6. 解决Linux操作系统下AES解密失败的问题
  7. android开发关掉发现更新的官方版本,XUpdate:轻量级、高可用性的 Android 版本更新框架...
  8. python 01列表异或_python运算符及优先级顺序
  9. list排序sort降序_list.sort和高阶函数sorted
  10. 全国身份证号码归属地表格
  11. 线性二次型调节器(LQR)原理详解
  12. 集群通信组件Tribes之整体介绍
  13. 一个菜鸟关于winrar密码无法秒破的研究结果
  14. 高德地图可视化3D地图区域上添加棱柱
  15. 哥德巴赫猜想c#语言,哥德巴赫猜想算法c#实现方法
  16. H3C交换机SNMP配置
  17. python binascii.b2a_hex_python标准模块介绍- binascii 二进制和ASCII转换
  18. uniapp 微信小程序 控制台警告和错误处理
  19. b区计算机专业调剂容易的学校,2021考研b区容易调剂的学校有哪些
  20. js中的escape方法有什么用?

热门文章

  1. 域名dns被劫持怎么办、dns被劫持怎么办、dns被劫持的解决方法
  2. 机器学习判定红楼梦后40回是否曹雪芹所写
  3. 2022: LAVT: Language-Aware Vision Transformer for Referring Image Segmentation
  4. 数据分析神经网络模型图,神经网络模型数据处理
  5. 使用 npm 打包项目
  6. FOJ 1921 栀子花开 线段树裸题
  7. 美国人如何看待超自然?
  8. 删除后别人的微信号变成wxid_重磅!只需三步修改微信号,不用设置出生日期...
  9. (1)桌面客制化之单屏幕修改以及wight修改
  10. SEP8266 由零开始(一),最小系统,下载,与WiFi建立