CSP第23次 202109-1 数组推导 C语言满分答案
#include <stdio.h>
int main()
{
int i,j,k;
int n;
scanf("%d",&n);
int max=0,min=0;
int l_tmp=0;
scanf("%d",&l_tmp);
max = l_tmp;
min = l_tmp;
for(i=0;i<n-1;i++)
{
int tmp;
scanf("%d",&tmp);
if(tmp==l_tmp)
max+=tmp;
else
{
max+=tmp;
min+=tmp;
}
l_tmp = tmp;
}
printf("%d\n%d",max,min);
return 0;
}