其他分享
首页 > 其他分享> > HYSBZ-3043 IncDec Sequence

HYSBZ-3043 IncDec Sequence

作者:互联网

 

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cmath>
 4 #include <stdio.h>
 5 #include <cstring>
 6 #include <string>
 7 #include <cstdlib>
 8 #include <queue>
 9 #include <stack>
10 #include <set>
11 #include <vector>
12 #include <map>
13 #include <list>
14 #include <iomanip>
15  #include <fstream>
16 using namespace std;
17 
18 typedef long long ll;
19 
20 ll a[100007],pos,neg;
21 int main()
22 {
23     ll n,l,r;
24     scanf("%lld",&n);
25     for(int i=1;i<=n;++i)
26     {
27         scanf("%lld",&a[i]);
28      } 
29      
30     for(int i=n;i>1;i--)
31     {
32         if(a[i]-a[i-1]>0)
33             pos+=a[i]-a[i-1];
34         else
35             neg+=a[i-1]-a[i];    
36     }
37     
38     printf("%lld\n%lld\n",max(pos,neg),abs(pos-neg)+1);
39     return 0;
40 }
View Code

 

标签:int,HYSBZ,ll,pos,neg,3043,include,IncDec,lld
来源: https://www.cnblogs.com/greenaway07/p/11188181.html