Posted on 2009-03-23 18:42
Hero 阅读(484)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1011 Accepted 0 120 899 C++
2 //排序后贪心
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7
8 const int oo = 2100000000 ;
9
10 const int size = 110 ;
11 int A[size] ;
12 int B[size] ;
13
14 int tnum ;
15 int inn ;
16
17 int cmp( const void *a, const void *b )
18 {
19 return *(int *)b - *(int *)a ;
20 }
21
22 int main()
23 {
24 while( scanf( "%d", &tnum) != EOF )
25 {
26 while( tnum -- )
27 {
28 scanf( "%d", &inn ) ;
29 for( int i=1; i<=inn; i++ ) scanf( "%d", &A[i] ) ;
30 for( int i=1; i<=inn; i++ ) scanf( "%d", &B[i] ) ;
31 B[inn+1] = oo ;
32
33 qsort( A+1, inn, sizeof(A[1]), cmp ) ;
34 qsort( B+1, inn, sizeof(B[1]), cmp ) ;
35
36 int left = 1 ; int win = 0 ;
37 for( int i=1; i<=inn; i++ )
38 {
39 if( left > inn ) break ;
40 while( left<=inn && A[i]<B[left] ) left++ ;
41 if( left > inn ) break ;
42
43 win++ ; left++ ;
44 }
45
46 int out = ( win-(inn-win) ) * 200 ;
47
48 printf( "%d\n", out ) ;
49 }
50
51 }
52
53 return 0 ;
54 }