UVALive - 4094 WonderTeam (greedy)

Topic meaning:

There are n teams, each two teams play two games (one for home and away), 3 points for a win, 1 point for a draw, and no points for a loss. After the game, a dream team will be selected. The dream team meets the following requirements: Conditions: The most goals scored, the most victories, the least total losses, all three cannot be tied, the lowest ranking of the dream team

 

Analysis from: https://blog.csdn.net/l123012013048/article/details/44001543

analyze

1. Let the total number of goals in the dream team's winning field reach infinity (of course, this is impossible), the losing field will be scored 0 goals and the opponent team will score 1 goal, and the tie field will be scored 0:0, so Even if the dream team only wins one game, they can achieve the most goals. When the other teams are in a draw, let the total number of goals conceded is greater than the total number of goals conceded by the dream team, so that the total number of goals conceded by the dream team is the least.

2. The number of victories is the most, and the score of victories is 3 points. If the dream team is to be ranked as low as possible, the number of victories should not be too many, and the number of losses should be a little more.

So let the dream team only win two games and the other teams win one game, so that the dream team ranking can be launched.

Team Win/Loss Total Score

Dream Team 2 n-1 n-3 n+3

Team 1 1 1 2 n-4 2n-1  

Team 2 1 1 2n-4 2n-1

Other teams 1 0 2n-3 2n

It can be deduced from the above

Dream Team 1st place when n <= 3

2nd place when n == 4

Last place when n > 4

 

#include<cstdio>  
  
int main() {  
    int n;  
    while( scanf("%d",&n) == 1 && n ) {  
        if(n <= 3)  
            printf("1\n");  
        else if(n == 4)  
            printf("2\n");  
        else  
            printf("%d\n",n);  
    }  
    return 0;  
}  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325097054&siteId=291194637