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

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;
}

最新文章

  1. Spring bean依赖注入、bean的装配及相关注解
  2. cookies插件,记住cookies
  3. IOS数据存储之FMDB数据库
  4. discuz 3.x 核心文件class_core.php解析
  5. 被滥用的for in循环
  6. OS X Yosemite Beta体验
  7. (四)装饰模式-C++实现
  8. 《Linux内核分析》第一周 计算机是如何工作的?
  9. IOS asc码替换
  10. 第二十四课:jQuery.event.remove,dispatch的源码解读
  11. php(验证网址是否存在)错误
  12. java如何在函数中调用主函数的数组
  13. 它们的定义Adapterg在etView( )正在使用View.setTag()与不同的是不使用。
  14. JSP 语法/标签
  15. Grails笔记三:完整的文件上传实例
  16. Uva - 210 - Concurrency Simulator
  17. .Net Core应用框架Util介绍(三)
  18. overlay fs挂载及操作测试
  19. Linux服务器---流量监控bandwidthd
  20. bootstrap3显示5列的方法

热门文章

  1. wx.previewimage预览返回会触发onshow的处理方法
  2. 新闻网大数据实时分析可视化系统项目——18、Spark SQL快速离线数据分析
  3. HomePod即将发售,但硬件不再是苹果的救命稻草
  4. linux7下nenux3.14的maven私服搭建和配置使用
  5. 使用JMX连接JVM
  6. java随机函数用法Random
  7. 剑指offer,双指针法,vector输出不完美
  8. 015.Oracle数据库,取本月月初,取本月月末
  9. 时间戳,秒级,毫秒级转换DateTime格式
  10. 51nod 1293:球与切换器