Poj 2287 Tian Ji -- The Horse Racing

Source: Internet
Author: User

Poj 2287 Tian Ji -- The Horse Racing
Poj 2287 Tian Ji -- The Horse Racing

Question:
Tianji horse racing
If three horses are changed to 1000, Qi Wang still sets his horse to compete in the order of superiority to inferiority. Tian Ji can select his horse racing in any order. If you win a game, Tian Ji will get 200 silver coins. If you lose one game, Tian Ji will lose 200 silver coins.
How much money can Tian Ji win at most?

Ideas:
Greedy;
If Marco is the best horse to win the best horse of the king, make the two horses match each other;
If the worst horse can win the worst horse of Qi Wang at present, the two horses will match each other;
If neither of the above conditions is met, make the worst horse and the best horse match of Qi Wang.

/* Poj 2287 question: if three horses are converted into 1000 horses, Qi Wang still sets his horse to compete in the order of superiority to inferiority, tian Ji can select his horse racing competition in any order. If you win a game, Tian Ji will get 200 silver coins. If you lose one game, Tian Ji will lose 200 silver coins. How much money can Tian Ji win at most? Idea: greedy; if Marco is the best horse to win King Qi, the two horses will match each other; if the worst horse can win King Qi's worst horse, make the two horses match each other. If neither of the above conditions is met, make the worst horse and the best horse of Qi Wang match each other. */# Include
 
  
# Include
  
   
# Define deusing namespace std; const int N = 1005; int a [N], B [N]; void gao (int n) {int p1 = 0, p2 = 0; int q1 = n-1, q2 = n-1; int ans = 0; while (p1 <= q1) {if (a [p1]> B [p2]) {++ p1; ++ p2; ++ ans;} else if (a [q1]> B [q2]) {-- q1; -- q2; ++ ans ;} else {if (a [p1]! = B [q2]) -- ans; ++ p1; -- q2 ;}} printf (% d, ans * 200);} int main () {int n; while (scanf (% d, & n) {for (int I = 0; I
   
    

 

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.