Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA求助。。。

Posted by kidcanadian at 2011-02-17 12:49:45 on Problem 1304
#include <cstdio>
#include <cstring>
using namespace std;
int size[20];
char s[15];
char c[15];
int sum[15];
int nbus,i,j,arr;
int dur[20][10];
int main()
{

    while(scanf("%s",s)!=EOF)
    {
        if(strcmp(s,"ENDOFINPUT")==0)break;

        scanf("%d",&nbus);
        gets(s);
        memset(dur,0,sizeof(int)*20*10);
        memset(size,0,sizeof(size));
        for(i=0;i<nbus;i++)//读取部分
        {
            j=0;

            gets(c);
            for(int k=0;k<strlen(c);k++)
            {
                if(c[k]==' '||c[k]=='\n')
                {
                    j++;
                    continue;
                }
                else
                {
                    dur[i][j]=dur[i][j]*10+c[k]-'0';
                }
            }
            size[i]=++j;
        }//nbus
        scanf("%d",&arr);
        memset(sum,0,sizeof(sum));

        for(i=0;i<nbus;i++)
        {
            j=0;
            while(sum[i]<arr)
            {
                sum[i]+=dur[i][j%size[i]];
                j++;
            }
            sum[i]-=arr;


        }

        int min=sum[0];
        for(i=0;i<nbus;i++)
        {
            if(sum[i]<min)
                min=sum[i];
        }
        scanf("%s",s);
        printf("%d\n",min);


    }//while
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator