uva 11078

/**
 * @brief uva 11078
 * @file 11078
 * @author mianma
 * @created 2014/12/23 16:40
 * @edited  2014/12/23 16:40
 * @type 
 * @note
 */

#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cassert>

using namespace std;

#define max(a, b)  ((a) > (b) ? (a) : (b))
#define min(a, b)  ((a) > (b) ? (b) : (a)) 
#define abs(a)     ((a) >  0  ? (a) : (0 - (a)))
#define CLR(vec)   memset(vec, 0, sizeof(vec))

#define MAXN 100000
#define MAXV 150000

int T, n;
int record[MAXN + 10];
int table[MAXN + 10];

/*fast read IO*/
int read_int(){
    int neg = 0;
    int ch = getchar();
    while(!isdigit(ch) && '-' != ch)
        ch = getchar();
    if('-' == ch){
        ch = getchar();
        neg = 1;
    }
    int x = 0;
    while(isdigit(ch)){
        x  = x*10 + ch - '0';
        ch = getchar();
    }
    return ( neg ? 0 - x : x );
}

/*fast write IO*/
int write_int(int x){
    int neg = 0;
    static char buf[MAXV + 10];
    int n = 0;
    if(x < 0){
        neg = 1;
        x = abs(x);
    }
    while(x){
        buf[n++] = x%10 + '0';
        x       /= 10;
    }
    if(neg)
        putchar('-');
    for(int i = n -1 ; i >= 0; i--)
        putchar(buf[i]);
}

int main(void){
    int maxval, tmp;
#ifdef DEBUG
    freopen("./in", "r", stdin);
    freopen("./out", "w", stdout);
#endif
    scanf("%d", &T);
    while(T--){
        scanf("%d", &n);
        maxval = -MAXV - 10;
        for(int i = 1; i <= n; i++){
                record[i] = maxval;
                table[i] = read_int();
                maxval = max(maxval, table[i]);
        }
        maxval = -MAXV - 10;
        for(int i = 2; i <= n; i++)
                maxval = max(maxval, record[i] - table[i]);
        write_int(maxval);
        putchar('\n');
    }
    return 0;
}


转载于:https://my.oschina.net/u/572632/blog/360502

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值