| ||||||||||
| 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 "string.h"
struct car
{
int length;
char s[6];
};
int main()
{
int l,m,i,count,k,curlen,n,j;
scanf("%d",&n);
for(j=1;j<=n;j++)
{
scanf("%d%d",&l,&m);
struct car *a=new struct car[m];
for(i=0;i<m;i++)
{
scanf("%d%s",&a[i].length,a[i].s);
}
count=0;
if(strcmp(a[0].s,"right")==0)
count=1;
curlen=a[0].length;
i=1;
k=0;
while(i<m)
{
if(strcmp(a[k].s,a[i].s)==0)
{
curlen=curlen+a[i].length;
if(curlen>l*100)
{
count=count+2;
curlen=a[i].length;
k=i;
}
}
else
{
count=count+1;
k=i;
curlen=a[i].length;
}
i++;
}
printf("%d\n",count+1);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator