- #include <iostream>
- #include<algorithm>
- using namespace std;
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
-
- int main(int argc, char** argv) {
- long long int n,z=0,f=0,x;
- long long int a[100005],ans1,ans2;
- cin>>n;
- for(int i=1;i<=n;i++){
- cin>>a[i];
- }
- for(int i=2;i<=n;i++){
- x=a[i]-a[i-1];
- if(x>0){
- z+=x;
- }else if(x<0){
- f-=x;
- }
- }
- ans1=max(z,f);
- ans2=abs(z-f)+1;
- cout<<ans1<<endl<<ans2;
- return 0;
- }
洛谷P4552
最新推荐文章于 2025-04-15 15:54:08 发布