/* Main topic: Tian Bogey and King horse racing, Tian bogey every win a game can win 200 yuan, lose 200, draw no profit or loss. Eg:3---On behalf of each person has a few horses, the----Tian bogey horse----------The King's horse greedy strategy: first, when Tian bogey fastest King ponies the fastest horse, with Tian bogey fastest horse win the King's fastest horse. Second, when Tian bogey the fastest ponies king of the fastest horse slow, with Tian bogey the slowest horse to the King's fastest horse. Third, when Tian bogey the fastest horse with the king's fastest horse as fast as the situation. 1, when Tian bogey the slowest ponies king the slowest horse fast, so with Tian bogey the slowest horse to win the King's slowest horse 2, when the most slow ponies king of the slowest horse slow, then the most slow horse with Tian bogey to the king of the fastest horse 3, when the most slow horse with the king of the slowest minamisoma and so on, with Tian bogey the slowest horse with the king of the fastest Ma */# include <stdio.h>int main (void) {int num = 0;int tianji[10],king[10];while (scanf ("%d", &num)! = EOF) {getc Har (); Absorbs the carriage return character. int sum = 0;int T = 0,te = Num-1;int K = 0,ke = num-1;if (num = = 0) break;for (int i = 0; i < num; i++) {scanf ("%d", & Tianji[i]);} for (int j = 0; j < Num; J + +) {scanf ("%d", &king[j]);} while (num--) {if (tianji[t] > King[k]) {t++; K++;sum = sum + 200;} else if (Tianji[t] < king[k]) {te--; K++;sum = sum-200;} Else{if (Tianji[te] > King[ke]) {te--; Ke--;sum = sum + 200;} else if (Tianji[te] < King[ke]) {te--; K++;sum = sum-200;} Else{if (Tianji[te] > King[k])//Tian Bogey slow ponies King's fast horses slow {te--; K++;sum = sum-200;} else//Tian Bogey's slow horse and King's horse as fast as a draw {te--; k++;}}}} printf ("%d\n", sum);} return 0;}
HDU 1052 Tian Ji--The Horse Racing