UAV 11078 - Open Credit System
来源:互联网 发布:深圳旅游公司待遇知乎 编辑:程序博客网 时间:2024/05/29 04:01
Problem E
Open Credit System
Input: Standard Input
Output: Standard Output
In an open credit system, the students can chooseany course they like, but there is a problem. Some of the students are moresenior than other students. The professor of such a course has found quite anumber of such students who came from senior classes (as if they came to attendthe pre requisite course after passing an advanced course). But he wants to dojustice to the new students. So, he is going to take a placement test(basically an IQ test) to assess the level of difference among the students. Hewants to know the maximum amount of score that a senior student gets more thanany junior student. For example, if a senior student gets 80 and a juniorstudent gets 70, then this amount is 10. Be careful that we don't want theabsolute value. Help the professor to figure out a solution.
Input
Input consists of a number of test cases T (less than 20). Each case starts with an integer n which is the number of students inthe course. This value can be as large as 100,000 and as low as 2. Next n lines contain n integers where thei'th integer is the score of the i'thstudent. All these integers have absolute values less than 150000. Ifi <j, then i'thstudent is senior to the j'th student.
Output
For each test case, output the desired number in a newline. Follow the format shown in sample input-output section.
SampleInput Outputfor Sample Input
321002044321
4
1
2
3
4
80
3
-1
Problemsetter: Mohammad Sajjad Hossain
Special Thanks: Shahriar Manzoor
扫描一遍即可,同时维护前面的最大值
#include <cstdio>#include <iostream>#include <vector>#include <algorithm>#include <string>#include <cstring>#include <map>#include <cmath>#include <string>#include <queue>#include <set>using namespace std;#ifdef WINtypedef __int64 LL;#define iform "%I64d"#define oform "%I64d\n"#elsetypedef long long LL;#define iform "%lld"#define oform "%lld\n"#endifconst int INF = 0x3f3f3f3f;const int maxn = 100 + 10;int main() {int T;scanf("%d", &T);while(T--) {int n;int ans = -INF;int tmax;scanf("%d%d", &n, &tmax);for(int i=1; i<n; i++) {int t;scanf("%d", &t);if(tmax - t > ans) {ans = tmax - t;}tmax = max(tmax, t);}printf("%d\n", ans);}return 0;}
- UAV 11078 - Open Credit System
- 11078 - Open Credit System
- 11078 - Open Credit System
- 11078Open Credit System
- UVA 11078 Open Credit System
- Uva-11078-Open Credit System
- UVA 11078 - Open Credit System
- uva 11078 Open Credit System
- UVa 11078 - Open Credit System
- UVA 11078 Open Credit System
- UVA 11078 Open Credit System
- UVa:11078 Open Credit System
- UVA - 11078 Open Credit System
- Open Credit System UVa 11078
- UVA 11078 Open Credit System
- UVA 11078 - Open Credit System
- uva 11078 Open Credit System
- UVA 11078 Open Credit System
- python 在 eclipse 中 导入 scrapy源码 进行调试,并安装 setuptools easy_install
- php session 单线程 导出卡死
- java.util.ResourceBundle使用详解
- 常用用的header状态值,记录下来以免忘记
- 不能用循环和本地变量,对一个整形n,实现输出n,2n,4n,...当大于max(比如5000)时再逆向输出...4n,2n,n
- UAV 11078 - Open Credit System
- PS里面不改变背景的情况下去掉文字的几种方法
- html块级元素和内联元素区别详解
- 最小生成树
- db2 重新编目
- Storyboard下实现的ScrollView内添加控件后无法滚动问题
- IIS7下 设置discuzX3伪静态
- perl的特殊变量$^I
- Linux的cat命令总结