uva 11078 Open Credit System

简介: 点击打开链接uva11078 水题 对于一个确定的j来说,要求num[i]是最大的,所以我们枚举j然后维护最大的num[i],然后同时求最大的ans即可 #include#include#include#includeusin...

点击打开链接uva11078

水题

对于一个确定的j来说,要求num[i]是最大的,所以我们枚举j然后维护最大的num[i],然后同时求最大的ans即可

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    const int MAXN = 100010;
    int Case , n , ans , num[MAXN];
    scanf("%d" , &Case);
    while(Case--){
        scanf("%d" , &n); 
        for(int i = 0 ; i < n ; i++)
           scanf("%d" , &num[i]);
        ans = -2147483647;
        int Max = num[0]; 
        for(int i = 1 ; i < n ; i++){
           ans = max(ans , Max-num[i]); 
           Max = max(Max , num[i]); 
        }
        printf("%d\n" , ans); 
    } 
    return 0;
}



目录
打赏
0
0
0
0
15
分享
相关文章
uva101 The Blocks Problem
uva101 The Blocks Problem
66 0
UVa12478 - Hardest Problem Ever (枚举)
UVa12478 - Hardest Problem Ever (枚举)
56 0
How to assign free areas? | Operating system principle
How to assign free areas? | Operating system principle
75 0
P3146 [USACO16OPEN]248 G
P3146 [USACO16OPEN]248 G
102 0
P3146 [USACO16OPEN]248 G
error: insufficient permissions for device
error: insufficient permissions for device
439 0
CTU Open Contest 2019 部分题解
CTU Open Contest 2019 部分题解
90 0
SAP公司间STO里发货单过账后触发的IDoc报错 – Could not find code page for receiving system –
SAP公司间STO里发货单过账后触发的IDoc报错 – Could not find code page for receiving system –
SAP公司间STO里发货单过账后触发的IDoc报错 – Could not find code page for receiving system –
ONOS(Open Network Operating System) from ONF
相关链接: https://www.sdnlab.com/tag/onos/ https://github.com/opennetworkinglab/onos https://en.wikipedia.org/wiki/ONOS
1277 0
POJ 1018 Communication System
Communication System Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28182   Accepted: 10049 Description We have received an order from Pizoor Communications Inc.
1490 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等