A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题
---恢复内容开始---
standard output
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 a_1 players in the first team and a_2 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 k_1 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 k_2 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.
The first line contains one integer a_1 (1 \le a_1 \le 1\,000) — the number of players in the first team.
The second line contains one integer a_2 (1 \le a_2 \le 1\,000) — the number of players in the second team.
The third line contains one integer k_1 (1 \le k_1 \le 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 k_2 (1 \le k_2 \le 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 \le n \le a_1 \cdot k_1 + a_2 \cdot k_2) — the number of yellow cards that have been shown during the match.
Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.
2
3
5
1
8
0 4
3
1
6
7
25
4 4
6
4
9
10
89
5 9
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 \cdot 6 + 1 \cdot 7 = 25), so in any case all players were sent off.
地址:http://codeforces.com/contest/1215/problem/A
题意:


对于最少的情况:两队分别是k1,k2张,那么让每个人得k1-1,k2-1张。一共为 m==a1*(k1-1)+a2*(k2-1); 这个m就是,如果n>m,就可以有人下场,n<=m,用贪心思想,可以做到无人下场。n>m的时候,由于k1-1,k2-1的原因,每个人只需要1票就下场了。让每个人都得到了k1-1,k2-1的票数,那么n每比m多一个,就一个人下场所以此时n-m即为最少下场人数。
对于最大的情况:我习惯用k1<k2,所以做了swap的处理。
求最大,肯定从需票数少的一队入手。a2*k2如果大于等于n,那么直接就是max==n/k2;否则,n=n-n/k2;用这个余下的n去比上k1即可了。
主要是思想,最少的情况里,根据贪心思想,要想一个人不退场,那么我的总票数不能大于 a1*(k1-1)+a2*(k2-1),如果大于了,这个操作使每个人只需一票就要下场了,n-就可以了。
上代码:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a1,a2,k1,k2,n;
cin>>a1>>a2>>k1>>k2>>n;
int minn,maxx=;
int k=a1*(k1-)+a2*(k2-);
if(n<=k)
minn=;
else
{
minn=n-k;
}
if(k1<k2)
{
swap(k1,k2);
swap(a1,a2);
}
// cout<<a2<<" "<<k2<<endl;
if(a2*k2<n)
{
maxx+=a2;
n-=a2*k2;
maxx+=n/k1; }
else
{
maxx+=n/k2;
}
cout<<minn<<' '<<maxx<<endl;
}
A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题的更多相关文章
- Codeforces Round #336 (Div. 2)-608A.水题 608B.前缀和
A题和B题... A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabyte ...
- Codeforces Round #345(Div. 2)-651A.水题 651B.。。。 651C.去重操作 真是让人头大
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #315 (Div. 2) B 水题强行set
B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- Codeforces Round #585 (Div. 2) A. Yellow Cards(数学)
链接: https://codeforces.com/contest/1215/problem/A 题意: The final match of the Berland Football Cup ha ...
- Codeforces Round #585 (Div. 2)
https://www.cnblogs.com/31415926535x/p/11553164.html 感觉很硬核啊这场,,越往后越做不动,,,emmmm,,,(这场是奔着最后一题 2sat 来的, ...
- Codeforces Round #585 (Div. 2) [补题]
前言 2019.9.16 昨天下午就看了看D题,没有写对,因为要补作业,快点下机了,这周争取把题补完. 2019.9.17 这篇文章或者其他文章难免有错别字不被察觉,请读者还是要根据意思来读,不要纠结 ...
- Codeforces Round #585 (Div. 2) CF1215A~C
CF1215A. Yellow Cards简单的模拟,给定了黄票张数,判断最少和最多有多少人被罚下场. #include <bits/stdc++.h> using namespace s ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
随机推荐
- vue实现登陆单页面
一 实现页面的布局 1. 首先在components里建一个login.vue <template> <div class=login_container> 登陆组件 < ...
- 实验吧——Recursive
环境:win10,kali虚拟机 工具:ida 虚拟机打开看看,发现是ELF文件,运行一下,额没有什么发现. Ida打开看看,发现是在文件内部运行python解释器,百度搜索了一个基本上可以找到Py_ ...
- push 和 append 以及appendchild 用法和区别
push() 给数组添加元素,并且返回数组长度 如 : arr.push('a') append() 是jq写法,添加节点到指定父级节点的子节点列表末尾 appendchild() 是append原生 ...
- 一个自己实现的Vector 完善版本
一个自己实现的Vector(只能处理基本类型数据) 转载自: https://www.ev0l.art/index.php/archives/22/ string 类型不行 bool char* in ...
- 032.SAP上用户无法打开PPE模块,查看并开通用户的PPE权限
01. 用户使用PPE模块之后,提示没有为iPPE工作台分配一个用户参数,如图所示: 02. 如果是管理员账号,则可以点击右下角的问号,来到下面界面 03.点击iPPE 用户分配者几个蓝色的字,进入下 ...
- SNOI2019 选做
施工中... d1t1 字符串 题面 考虑两个字符串 \(s_i,s_j(i<j)\) ,实质是 \(s[i+1,\dots j]\) 和 \(s[i,\dots ,j-1]\) 的字符串字典序 ...
- CentOS7.x关闭防火墙
使用命令:systemctl status firewalld.service 查看防火墙状态 执行后可以看到绿色字样标注的“active(running)”,说明防火墙是开启状态 使用命令:syst ...
- 解析underscore中的throttle
什么是throttle(节流) Throttling enforces a maximum number of times a function can be called over time. 简单 ...
- 使用Hibarnate: 出现 java.sql.SQLException: ORA-00911: 无效字符, 解决思路
1. 查看到: Hibernat自动生成的sql查询语句 Hibernate: select * from ( select module0_.MODULE_ID as MODULE_ID1_1_, ...
- mysql 免安装版后续操作
在安装好mysql后,软件默认的root用户的密码为空. 1.进入mysql 2.创建数据库 3.创建表格 4.插入数据 5.显示数据库.表信息