20000
There are multiple groups of test data. For each group of test data, enter a number n in the first line, which indicates that n horses are involved in the competition. Then, enter two rows of data, first, Tian Ji's speed of every horse, second, Qi Wang's speed of every horse, and output a line indicating the amount of money that Tian Ji Won (200 at a time, and 200 at a time)
# Include <stdio. h> # include <stdlib. h> int tian [1005], king [1005]; // sort int com (const void * a, const void * B) in ascending order) {return (* (int *) B-* (int *) a);} // read the speed of each horse void read (int n) {int I; for (I = 0; I <n; I ++) {scanf ("% d", & tian [I]) ;}for (I = 0; I <n; I ++) {scanf ("% d", & king [I]) ;}// calculate the number of wins int match (int n) {qsort (tian, n, sizeof (tian [0]), com); qsort (king, n, sizeof (king [0]), com); int tl, tf, kl, kf, win, lose; tl = kl = n-1; tf = kf = 0; win = l Ose = 0; while (tf <= tl) // traverse {if (tian [tf]> king [kf]) {// if tian Ji's fastest horse is faster than Qi Wang's fastest horse, win a game win ++; tf ++; kf ++;} else if (tian [tl]> king [kl]) {// If Tian Ji's slowest horse is faster than Qi Wang's slowest horse, win a win ++; tl --; kl --;} else {if (tian [tl] <king [kf]) // if tian Ji's slowest horse is slower than Qi Wang's fastest horse, lose is a lose ++; tl --; kf ++ ;}}return (win-lose) * 200 ;}int main () {int n; while (scanf ("% d", & n )! = EOF) {read (n); printf ("% d \ n", match (n);} return 0 ;}