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