Codeforces Round #585 (Div. 2) A.Yellow Cards

Idea: It’s easy to ask for the maximum. First, calculate whether the team with a smaller number of yellow cards can be penalized. If the number is not enough, you need to make up another team.

To find the minimum, you need to think about it. The method is to multiply k-1 by the corresponding number (that is, the critical value penalized). If it is greater than, just subtract it (because the difference is 1 at this time). Need someone to end

Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
 
    int a1,a2,k1,k2,m,n,k;
    int num1=0,num=0,mul,div,mul1;
    cin>>a1>>a2>>k1>>k2>>m;
    n=m;
    if(k1>k2)
    {
        div=n/k2;
        if(div<=a2)
        {
            num=div;
        }
        else if(div>a2)
        {
            num+=a2;
            n-=k2*a2;
            num+=n/k1;
        }
        mul1=(k1-1)*a1+(k2-1)*a2;
        if(mul1>m)
        {
            num1=0;
        }
        else
        {
        mul=k1*a1;
        if(mul>m)
        {
            num1=0;
        }
        else
        {
            num1=m-mul1;
        }
        }
        cout<<num1<<" "<<num<<endl;
    }
    else
    {
        div=n/k1;
        if(div<=a1)
        {
            num=div;
        }
        else if(div>a1)
        {
            num+=a1;
            n-=k1*a1;
            num+=n/k2;
        }
        mul1=(k1-1)*a1+(k2-1)*a2;
        if(mul1>m)
        {
            num1=0;
        }
        else
        {
         mul=k2*a2;
        if(mul>m)
        {
            num1=0;
        }
        else
        {
            num1=m-mul1;
        }
        }
        cout<<num1<<" "<<num<<endl;
    }
    return 0;
 
}

 

 

Title:

The final of the Berlin Football Cup was held recently. The referee showed nn yellow cards throughout the game. At the start of the game, the first team has 1 player and the second team has 2 players.

In Berlin football, the rules for sending off players are a bit different. If a team player receives k1 yellow cards during the entire game, he can no longer participate in the game-he is sent off. If a player of the second team receives K2 yellow cards, he will be sent off. After the player leaves the game, he can no longer receive any yellow cards. Each of the N yellow cards is shown to a player. Even if all players from one team (or even from two teams) leave the game, the game will continue.

The referee lost his record of who received the yellow card. Help him determine the minimum and maximum number of players that may be kicked out of the game.

enter:

The first line contains an integer a1 (1≤a1≤1000)-the number of players in the first team.

The second line contains an integer a2 (1≤a2≤1000)-the number of players in the second team.

The third line contains an integer k1 (1≤k1≤1000)-the maximum number of yellow cards that a team player can receive (after receiving many yellow cards, he will withdraw from the game).

The fourth line contains an integer k2 (1≤k2≤1000)-the maximum number of yellow cards that the second group of players can receive (after receiving so many yellow cards, he leaves the game).

The fifth line contains an integer nn (1≤n≤a1 k1+a2 k2)

-The number of yellow cards shown during the game.

Output:

Print two integers-the minimum and maximum number of players that may be kicked out of the game.

 

 

 

 


 

Guess you like

Origin blog.csdn.net/weixin_44067773/article/details/100973071