[C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces
1 Problem Description
Problem
The final match of the Berland Football Cup has been held recently. The referee has shown n yellow cards throughout the match. At the beginning of the match there were a1 players in the first team and a2 players in the second team. The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives k1 yellow cards throughout the match, he can no longer participate in the match — he’s sent off. And if a player from the second team receives k2 yellow cards, he’s sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of n yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues. The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.Input
The first line contains one integer a1 (1 ≤ a1 ≤ 1 000) — the number of players in the first team.The second line contains one integer a2 (1 ≤ a2 ≤ 1 000) — the number of players in the second team.The third line contains one integer k1 (1 ≤ k1 ≤ 1 000) — the maximum number of yellow cards a player from the first team can receive (after receiving that many yellow cards, he leaves the game).The fourth line contains one integer k2 (1 ≤ k2 ≤ 1 000) — the maximum number of yellow cards a player from the second team can receive (after receiving that many yellow cards, he leaves the game).The fifth line contains one integer n (1 ≤ n ≤ a1 · k1 + a2 · k2) — the number of yellow cards that have been shown during the match.Output
Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.Examples
- Note
In the first example it could be possible that no player left the game, so the first number in the output is 0. The maximum possible number of players that could have been forced to leave the game is 4 — one player from the first team, and three players from the second.
In the second example the maximum possible number of yellow cards has been shown (3 · 6 + 1 · 7 = 25),so in any case all players were sent of
2 Problem Analysis
3 Code
/*
Yellow Cards - GYM - 102348 - Problem:A - 2019-09-29
[Problem Description] https://codeforces.com/gym/102348/problem/A
[Contest Material] https://codeforces.com/gym/102348/attachments/download/9362/statements.pdf
[Contest Information]
[Name] Southern and Volga Russia Qualifier 2019-2020 (GYM)
[Start] Sep/17/2019 00:00UTC+8
[Length] 04:00 (Hour)
[Other] Final standings / Prepared by BledDest Official ICPC Contest Northeastern Europe Region Russia, Saratov, 2019-2020 Statements: in English, in Russian
*/
#include<stdio.h>
#include<iostream>
using namespace std;
int min(int a1, int a2, int k1, int k2, int n){
int total = a1*(k1-1) + a2*(k2-1);
if(n <= total){
return 0;
} else {
return (n - total);
}
}
int max(int a1, int a2, int k1, int k2, int n){
int minTeamOfYellowCardsNum[2];
minTeamOfYellowCardsNum[0] = k1<k2?a1:a2;
minTeamOfYellowCardsNum[1] = k1<k2?k1:k2;
int temp1 = minTeamOfYellowCardsNum[0]*minTeamOfYellowCardsNum[1];
int temp2 = a1*k1 + a2*k2;
//printf("Amin*Kmin: %d\n", temp1);
//printf("A1*K1+A2*K2: %d\n", temp2);
if(n <= temp1){
return n/minTeamOfYellowCardsNum[1];// n < temp1
} else {
//printf("n/minTeamOfYellowCardsNum[1]: %d\n", n/minTeamOfYellowCardsNum[1]);
//printf("n: %d | Amin*Kmin(temp2): %d\n",n, temp2);
int maxTeamOfYellowCardsNum[2];
maxTeamOfYellowCardsNum[0] = k1>k2?a1:a2;
maxTeamOfYellowCardsNum[1] = k1>k2?k1:k2;
return minTeamOfYellowCardsNum[0] + ( ( n - temp1 )/maxTeamOfYellowCardsNum[1]);
}
}
int main(){
int a1,a2;
int k1,k2;
int n;
scanf("%d\n%d\n%d\n%d\n%d", &a1, &a2, &k1, &k2, &n);
//printf("%d\n%d\n%d\n%d\n%d\n", a1, a2, k1, k2, n);//test output
printf("%d\n", min(a1, a2, k1, k2, n));
printf("%d", max(a1, a2, k1, k2, n));
return 0;
}
Congratulations~
4 Problem Related Information
- [Problem Description]
- [Contest Material]
- [Contest Information]
- [Name] Southern and Volga Russia Qualifier 2019-2020 (GYM)
- [Start] Sep/17/2019 00:00UTC+8
- [Length] 04:00 (Hour)
- [Other Information]
- Final standings
- Prepared by BledDest Official ICPC Contest Northeastern Europe Region Russia, Saratov, 2019-2020 Statements: in English, in Russian
5 Recommend Documents
- 1 Codeforces游玩攻略 - About CodeForces - 知乎
- 2 在玩acm的大佬眼中codeforces这个平台怎么样? - Author:hzwer - 北京大学(计算机视觉) - About CodeForces - 知乎
- 3 在玩acm的大佬眼中codeforces这个平台怎么样? - Author:ccsu cat - About CodeForces - 知乎
- 4 洛谷
- 5 CodeForces
[C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces的更多相关文章
- Codeforces Round #585 (Div. 2) A. Yellow Cards(数学)
链接: https://codeforces.com/contest/1215/problem/A 题意: The final match of the Berland Football Cup ha ...
- A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题
---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recent ...
- 【Yellow Cards CodeForces - 1215A 】【贪心】
该题难点在于求最小的离开数,最大的没什么好说的,关键是求最小的. 可以这样去想,最小的离开数就是每个人获得的牌数等于他所能接受的最大牌数-1,这样就可以直接比较m=a1(k1-1)+a2(k2-1)与 ...
- Game of Cards Gym - 101128G (SG函数)
Problem G: Game of Cards \[ Time Limit: 1 s \quad Memory Limit: 256 MiB \] 题意 题意就是给出\(n\)堆扑克牌,然后给出一个 ...
- CodeForces 471C MUH and House of Cards
MUH and House of Cards Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & % ...
- Codeforces Round #384 (Div. 2) E. Vladik and cards 状压dp
E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way ...
- Gym100947E || codeforces 559c 组合数取模
E - Qwerty78 Trip Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- Codeforces Round #281 (Div. 2)
题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football gam ...
- CodeForces 512B(区间dp)
D - Fox And Jumping Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64 ...
随机推荐
- 机器学习 三剑客 之 pandas + numpy
机器学习 什么是机器学习? 机器学习是从数据中自动分析获得规律(模型),并利用规律对未知数据进行预测 机器学习存在的目的和价值领域? 领域: 医疗.航空.教育.物流.电商 等... 目的: 让机器学习 ...
- bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行
bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行 判断 @echo off net.exe session 1>NUL 2>NUL && ( goto ...
- Nginx服务器的Websockets配置方法
这篇文章主要介绍了简介Nginx服务器的Websockets配置方法,是使用Nginx服务器的网管的必备知识XD~需要的朋友可以参考下 Nginx 1.3.13 已经发布了,该版本支持 Connect ...
- DeviceSupport 路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSuppor
- 分享一个我改进过的ocr算法
https://github.com/zhangbo2008/chineseOCR-jingjianban 欢迎大家前来拍砖
- halcon基础数据类型详解
#if defined(__CHAR_UNSIGNED__) || defined(__sgi) #define INT1 signed char /* integer, signed 1 Byte ...
- 4、获取Class中的构造函数
4.获取Class中的构造函数 4.1 早期创建对象 早期创建对象,先根据被new的类的名称找寻该类的字节码文件,并加载进内存,并创建该字节码文件对象,并接着创建该接文件的对应的Person对象 co ...
- linux笔试题
1. cron 后台常驻程序 (daemon) 用于: A. 负责文件在网络中的共享 B. 管理打印子系统 C. 跟踪管理系统信息和错误 D. 管理系统日常任务的调度 2. 在大多数Linux发行版本 ...
- Codeforces Round #495 (Div. 2) A,B,C
A题 1.新添加一间酒店,要求酒店离已有的最近的一间酒店的距离恰好等于d 2.最左和最右必定存在合适的两种情况 3.酒店之间的情况就要判断两间酒店间的距离: 小于2d,表示无法在这两间酒店中间找到合适 ...
- SP703 SERVICE - Mobile Service
思路:DP 提交:1次 题解: 我们把处理到的要求作为阶段. \(f[i][x][y][z]\)表示第 \(i\) 个要求,三个人分别的位置. 发现这样有很多无用状态,因为显然在第 \(i\) 个要求 ...