uva 11078 Open Credit System

点击打开链接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;
}
时间: 2024-11-29 15:25:03

uva 11078 Open Credit System的相关文章

UVA之11078 - Open Credit System

[题目] Problem E Open Credit System Input: Standard Input Output: Standard Output In an open credit system, the students can choose any course they like, but there is a problem. Some of the students are more senior than other students. The professor of

uva11078Open Credit System

题意:给定n个整数,求Ai-Aj的最大值(i<j), 2<=n<=100000 分析:简单模拟的话,用二重循环,O(n2)的复杂度肯定不行.对于每个Aj,只需要Ai最大就行,而最大的Ai可以通过相邻元素的比较获得,那么接下来枚举Aj即可,转化成O(n) 代码: View Code 1 #include <stdio.h> 2 #include <iostream> 3 #define DEBUG 4 using namespace std; 5 const int

Learn Blockchain and Smart Contract in 10 Minutes

So what is blockchain exactly?  In general, a blockchain implements a brand new credit system.  Another synonymous saying goes like this: the blockchain system is a "trustless" system that implements its own credit.  The credit system is not sub

区块链技术指南.

区块链技术指南 邹均 张海宁 唐屹 李磊 等著 图书在版编目(CIP)数据 区块链技术指南 / 邹均等著. -北京:机械工业出版社,2016.11 ISBN 978-7-111-55356-4 I. 区- II. 邹- III. 电子商务-支付方式-指南 IV. F713.361.3-62 中国版本图书馆CIP数据核字(2016)第268750号 区块链技术指南 出版发行:机械工业出版社(北京市西城区百万庄大街22号 邮政编码:100037) 责任编辑:高婧雅 责任校对:殷 虹 印 刷: 版 次

区块链技术指2.2 以太坊

2.2 以太坊 2.2.1 什么是以太坊 自2008年比特币出现以来,数字货币的存在已经渐渐为一部分人所接受.人们也积极展开了基于比特币的商业应用的思考与开发.但是随着应用的扩展,人们发现比特币的设计只适合虚拟货币场景,由于存在着非图灵完备性.缺少保存状态的账户概念,以及PoW挖矿机制所带来的资源浪费和效率问题,在很多区块链应用场景下并不适用.人们需要一个新的基于区块链的具有图灵完备性.高效共识机制.支持更多应用场景的智能合约开发平台.以太坊在这种情况下应运而生. 以太坊的目的是对脚本.竞争币和

UVa 111:History Grading

[题目链接] http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_problem&problem=47 [History Grading Background Many problems in Computer Science involve maximizing some measure according to constraints. C

UVa 10182 Bee Maja:规律&amp;amp;O(1)算法

10182 - Bee Maja Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1123 Maja is a bee. She lives in a bee hive with thousands of other bees. This bee hive c

UVa 10183 How Many Fibs? (统计斐波那契数个数&amp;amp;高精度)

10183 - How Many Fibs? Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=1124 Recall the definition of the Fibonacci numbers:    f1 := 1    f2 := 2    fn :

UVa 550 Multiplying by Rotation:模拟乘法

550 - Multiplying by Rotation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=491 Warning: Not all numbers in this problem are decimal numbers! Multiplic