---恢复内容开始---

output

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.

Input

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.

Output

Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.

Examples
input

Copy
2
3
5
1
8
output

Copy
0 4
input

Copy
3
1
6
7
25
output

Copy
4 4
input

Copy
6
4
9
10
89
output

Copy
5 9
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 \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) 思维水题的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Codeforces Round #609 (Div. 2)前五题题解

    Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...

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

    链接: https://codeforces.com/contest/1215/problem/A 题意: The final match of the Berland Football Cup ha ...

  6. Codeforces Round #585 (Div. 2)

    https://www.cnblogs.com/31415926535x/p/11553164.html 感觉很硬核啊这场,,越往后越做不动,,,emmmm,,,(这场是奔着最后一题 2sat 来的, ...

  7. Codeforces Round #585 (Div. 2) [补题]

    前言 2019.9.16 昨天下午就看了看D题,没有写对,因为要补作业,快点下机了,这周争取把题补完. 2019.9.17 这篇文章或者其他文章难免有错别字不被察觉,请读者还是要根据意思来读,不要纠结 ...

  8. Codeforces Round #585 (Div. 2) CF1215A~C

    CF1215A. Yellow Cards简单的模拟,给定了黄票张数,判断最少和最多有多少人被罚下场. #include <bits/stdc++.h> using namespace s ...

  9. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

随机推荐

  1. 2018--Linux面试题

    1.企业场景面试题:buffer与Cache的区别. 2.企业场景面试题:redhat与CentOS的区别. 3.企业场景面试题:  描述RAID 0 1 5 10的特点. 4.企业场景面试题:32位 ...

  2. C++ 动态多态

    背景 以前的学习,只是简单地知道:面向对象的三大特性(封装.继承.多态) ,在项目开发中,用到了多态而自己却不知道. 多态(Polymorphism)按字面的意思就是"多种状态". ...

  3. 2-10 就业课(2.0)-oozie:9、oozie与hue的整合,以及整合后执行MR任务

    5.hue整合oozie 第一步:停止oozie与hue的进程 通过命令停止oozie与hue的进程,准备修改oozie与hue的配置文件 第二步:修改oozie的配置文件(老版本的bug,新版本已经 ...

  4. 第2节 网站点击流项目(下):3、流量统计分析,分组求topN

    四. 模块开发----统计分析 select * from ods_weblog_detail limit 2;+--------------------------+---------------- ...

  5. wpf和winform的区别

    深入浅出WPF(7)——数据的绿色通道,Binding(上) 水之真谛关注6人评论28117人阅读2008-06-23 02:40:00  http://liuteimeng.blog.51cto.c ...

  6. 剑指offer第12题打印从1到n位数以及大整数加法乘法

       字符和数字加减就是字符的ASCII码和数字直接加减. 方法一: 1)在字符串操作中给一个整形数字加(字符0)就是把它转化为字符,当然给一个字符减去(字符0)就可以把它转化为数字了:如果确实是最后 ...

  7. Spring的JDBC的使用(配置和CRUD)

    导包: Spring的JDBC模板的使用 一.默认连接池 创建数据库 create database spring4; use spring4; create table account(id int ...

  8. pacificrack 控制面板登录不上的问题

    我今天又试了一下: https://master-stack01.pacificrack.com还是登不上(这个一键烦恼了我一个星期了,但是我今天百度出来了解决办法) 然后用这个就可以了  https ...

  9. Golang的常量定义及使用案例

    Golang的常量定义及使用案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.常量的定义 package main import ( "fmt" ) fu ...

  10. 内存寻址能力与CPU的位宽有关系吗?

    答案是:没有关系.CPU的寻址能力与它的地址总线位宽有关,而我们通常说的CPU位宽指的是数据总线位宽,它和地址总线位宽半毛钱关系也没有,自然也与寻址能力无关. 简单的说,CPU位宽指的是一个时钟周期内 ...