题目连接:
http://118.190.20.162/view.page?gpid=T129
代码:
#include<iostream>
using namespace std;
int main(){
int n,B = 0;
int lastB = 0;
int min,max;
cin >> n;
for(int i = 0;i < n;i++){
cin >> B;
if(i == 0){
min = max = B;
}else{
if(B > lastB){
max += B;
min += B;
}else if(B = lastB){
max += lastB;
min += 0;
}
}
lastB = B;
}
cout<<max<<endl;
cout<<min<<endl;
}
/*
max 0 0 5 5 10 10 30
min 0 0 5 0 10 0 15
A
B 0 0 5 5 10 10
*/