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(void) { int buffer[100000]; _int64 n,m,sum,temp; int i,t; scanf("%I64d %I64d",&n,&m); for(i=0;i<n;i++) { scanf("%d",&buffer[i]); } sum=0; t=buffer[0]; temp=0; for(i=0;i<n;i++) { if(temp+buffer[i]<=m && buffer[i]<=t) { temp+=buffer[i]; } else { if(buffer[i]>m) { sum=-1; break; } temp=t=buffer[i]; sum+=t; t=buffer[i]; } } sum+=t; printf("%I64d\n",sum); getchar(); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator