| ||||||||||
| 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 | |||||||||
我也终于找到错了用的方法和zhujie一样, 错也是错在细小的地方
通常我都是用t做临时变量的,这回t又成了测试次数的变量,导致2个变量重用了。
但是用sample的数据刚好是所有的si < ti的,导致交换部分的变量t没有改变
#include <stdio.h>
int main()
{
int a[200];
int n;
int i;
int x,y;
int t;
int max;
scanf("%d",&t);
while(t-->0)
{
for(i=0;i<200;i++)
a[i]=0;
scanf("%d",&n);
while(n-->0)
{
scanf("%d%d",&x,&y);
x=(x-1)/2;
y=(y-1)/2;
if(x>y)
{
int t; /*开始没有加这个导致和上面的变量t重用了*/
t=x;
x=y;
y=t;
}
/*printf("x=%d,y=%d\n",x,y);*/
for(i=x;i<=y;i++)
a[i]++;
}
max=0;
for(i=0;i<200;i++)
if(max<a[i])
max=a[i];
printf("%d\n",max*10);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator