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 |
贴个代码供大家参考#include <stdio.h> int main() { long n; scanf("%ld",&n); long a,b,c,k; long i; scanf("%ld",&a); for(i=1;i<n;i++) { if(i==1){ b = a; c = 0;} scanf("%ld",&a); k = c + a > b ? c + a: b; c = b - a > c ? b - a: c; b = k; } if(b > c) printf("%ld\n",b); else printf("%ld\n",c); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator