TJU训练赛—L
来源:互联网 发布:分区软件哪个好 编辑:程序博客网 时间:2024/05/16 15:31
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 286 Accepted Runs: 86
Given an array a with n intergers, please tell me the
Input
The input consists of multiple test cases. The first line contains an integer
Each case contains one integer
Output
For each case only output the answer.
Sample Input
151 3 5 4 2
Sample Output
4
【分析】
送分题....求这组序列中最大的a[j]-a[i],保证j>=i
因为j可以等于i所以最小值不会是负数,然后注意下只能用后面的数减去前面的数,所以不能求序列最大值和最小值减一下...
求一下1-i的最小值然后用当前读取的x-min跟ans判断一下求个max就好了
【代码】
#include <stdio.h>int main(){int pp;scanf("%d",&pp);while (pp--){int n;scanf("%d",&n);int now,x;scanf("%d",&now);int ans=0;for (int i=1;i<n;i++){scanf("%d",&x);if (x-now>ans) ans=x-now;if (x<now) now=x; }printf("%d\n",ans);}return 0;}
阅读全文
0 0
- TJU训练赛—L
- TJU训练赛—A
- TJU训练赛—B
- TJU训练赛—C
- TJU训练赛—D
- TJU训练赛—E
- TJU训练赛—G
- TJU训练赛—J
- 2013 - ECJTU 暑期训练赛第三场-problem-L
- 2013 - ECJTU 暑期训练赛第四场-problem-L
- 暑假编程训练---L:求多项式
- Codeforces 475A (五一训练 L)
- UESTC 数据结构专题训练 K,L,M
- Tju 3497 3495 (集训第一场练习赛)
- TJU ACM-ICPC Online Judge—1191 The Worm Turns
- TJU 3474
- TJU Sequence
- TJU Vacation
- hdu2577—How to Type(dp)
- Eclipse Modeling Framework, 2nd Edition. (EMF)学习笔记(一)——EMF介绍
- java正则表达式抓取网页图片
- 智慧警务指挥决策平台
- Python命令
- TJU训练赛—L
- gdfzoj #727 文本编辑(线段树)
- Ubuntu台式机有线没法上网
- Financial Concepts(1):Introduction
- iOS开发经验总结(三)
- 拦截导弹
- java数组和字符串相互转换
- Android测试框架
- Linux中如何产生core文件?