HDU 1052 Tian Ji--The Horse Racing

Source: Internet
Author: User

/* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.