Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪里还没考虑到啊,牛人看看啊,附代码wa#include <stdio.h> #include <stdlib.h> int main() { int i = 0,j,n,max,min,num=0,nb[150000]; scanf("%d",&n); for(j = 0; j < n; j++) { scanf("%d",&nb[j]); } while(i < n-1) { max = nb[i]; while(max < nb[++i]) { max = nb[i]; if(i == n-1) break; } num += max; if(i == n-1) { printf("%d\n",num); return 0; } min = nb[i]; while(min > nb[++i]) { min = nb[i]; if(i == n-1) { min = 0;break; } } num -= min; if(i == n-1) { printf("%d\n",num); return 0; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator