标签:des style blog io color os sp for 数据
5 3 1 2 4 3 5 3 1 2 4 1
2 3
#include <iostream> #include <string> #include <stdio.h> #include <algorithm> using namespace std; int MAX(int a, int b) { return a>b?a:b; } int main() { int n; int max, mm; int i, j; int dd, ff; while(scanf("%d", &n)!=EOF) { scanf("%d", &dd); scanf("%d", &ff); max=MAX(dd, ff); mm=dd-ff; for(i=2; i<n; i++) { scanf("%d", &dd); if(dd<=max) //当前段的最大值 { if((max-dd)>mm) mm=max-dd; } else { if((max-dd)>mm) mm=max-dd; max=dd; //更新当前段的最大值 } } cout<<mm<<endl; } return 0; }
标签:des style blog io color os sp for 数据
原文地址:http://www.cnblogs.com/yspworld/p/4138533.html