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 |
Dont know why WA?I have tested nearly all the datas that I could imagine. Please help me out and many thanks for you guys. # include <stdio.h> # include <stdlib.h> # include <string.h> int lenth[1000]; int n, k; int cmp ( const void *a, const void *b ) { return *(int *)a - *(int *)b; } int check ( int index ) { int sum = 0, i; for ( i = 0; i < k; i++ ) sum += lenth[index * k + i]; for ( i = 0; i < k; i++) if ( lenth[index * k + i] * k > sum * 2 ) return 1; return 0; } int main () { char name[81]; int i, flag, count = 1; freopen ("3312.txt", "r", stdin); while ( scanf ( "%d%d", &n, &k ) != -1 ) { if ( n == 0 && k == 0 ) break; flag = 0; for ( i = 0; i < n; i++ ) { scanf ( "%s", name ); lenth[i] = strlen ( name ); } qsort ( lenth, n, sizeof (int), cmp); for ( i = 0; i < n / k; i++ ) if ( check ( i ) ) { flag = 1; break; } printf ( "Case %d: ", count++); if ( flag ) puts ("no"); else puts ("yes"); puts (""); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator