| ||||||||||
| 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 | |||||||||
请各位高手指点迷津,为什么是wrong answer?#include<stdio.h>
void main()
{
int m,n,i,j,k1,k2,min,res ;
int count = 0 ;
while(1)
{
int data[2000] = {0} ;
res = 0 ;
count++ ;
scanf("%d%d",&m,&n) ;
if(m==0&&n==0)
break ;
scanf("%d",&min) ;
data[min] = 1 ;
for( i = 1 ; i < n ; i++ )
{
scanf("%d",&k1) ;
if( min > k1)
min = k1 ;
data[k1] = 1 ;
}
k1 = 0 ; k2 = 0 ;
i = m*n ;
while(1)
{
for( j = i ; data[j]==0 ; j-- )
k2++ ;
for( i = j ; data[i]==1&&i>=min; i-- )
k1++ ;
if(i<min)
{
if(k1>k2)
res += k1-k2 ;
break ;
}
if(k1>k2)
{
res += k1-k2 ;
k1=k2=0 ;
}
}
printf("case %d:%d\n",count,res) ;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator