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

  1. /*
  2. Yellow Cards - GYM - 102348 - Problem:A - 2019-09-29
  3. [Problem Description] https://codeforces.com/gym/102348/problem/A
  4. [Contest Material] https://codeforces.com/gym/102348/attachments/download/9362/statements.pdf
  5. [Contest Information]
  6. [Name] Southern and Volga Russia Qualifier 2019-2020 (GYM)
  7. [Start] Sep/17/2019 00:00UTC+8
  8. [Length] 04:00 (Hour)
  9. [Other] Final standings / Prepared by BledDest Official ICPC Contest Northeastern Europe Region Russia, Saratov, 2019-2020 Statements: in English, in Russian
  10. */
  11. #include<stdio.h>
  12. #include<iostream>
  13. using namespace std;
  14. int min(int a1, int a2, int k1, int k2, int n){
  15. int total = a1*(k1-1) + a2*(k2-1);
  16. if(n <= total){
  17. return 0;
  18. } else {
  19. return (n - total);
  20. }
  21. }
  22. int max(int a1, int a2, int k1, int k2, int n){
  23. int minTeamOfYellowCardsNum[2];
  24. minTeamOfYellowCardsNum[0] = k1<k2?a1:a2;
  25. minTeamOfYellowCardsNum[1] = k1<k2?k1:k2;
  26. int temp1 = minTeamOfYellowCardsNum[0]*minTeamOfYellowCardsNum[1];
  27. int temp2 = a1*k1 + a2*k2;
  28. //printf("Amin*Kmin: %d\n", temp1);
  29. //printf("A1*K1+A2*K2: %d\n", temp2);
  30. if(n <= temp1){
  31. return n/minTeamOfYellowCardsNum[1];// n < temp1
  32. } else {
  33. //printf("n/minTeamOfYellowCardsNum[1]: %d\n", n/minTeamOfYellowCardsNum[1]);
  34. //printf("n: %d | Amin*Kmin(temp2): %d\n",n, temp2);
  35. int maxTeamOfYellowCardsNum[2];
  36. maxTeamOfYellowCardsNum[0] = k1>k2?a1:a2;
  37. maxTeamOfYellowCardsNum[1] = k1>k2?k1:k2;
  38. return minTeamOfYellowCardsNum[0] + ( ( n - temp1 )/maxTeamOfYellowCardsNum[1]);
  39. }
  40. }
  41. int main(){
  42. int a1,a2;
  43. int k1,k2;
  44. int n;
  45. scanf("%d\n%d\n%d\n%d\n%d", &a1, &a2, &k1, &k2, &n);
  46. //printf("%d\n%d\n%d\n%d\n%d\n", a1, a2, k1, k2, n);//test output
  47. printf("%d\n", min(a1, a2, k1, k2, n));
  48. printf("%d", max(a1, a2, k1, k2, n));
  49. return 0;
  50. }

Congratulations~

4 Problem Related Information

5 Recommend Documents

[C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces的更多相关文章

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

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

  2. A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题

    ---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recent ...

  3. 【Yellow Cards CodeForces - 1215A 】【贪心】

    该题难点在于求最小的离开数,最大的没什么好说的,关键是求最小的. 可以这样去想,最小的离开数就是每个人获得的牌数等于他所能接受的最大牌数-1,这样就可以直接比较m=a1(k1-1)+a2(k2-1)与 ...

  4. Game of Cards Gym - 101128G (SG函数)

    Problem G: Game of Cards \[ Time Limit: 1 s \quad Memory Limit: 256 MiB \] 题意 题意就是给出\(n\)堆扑克牌,然后给出一个 ...

  5. CodeForces 471C MUH and House of Cards

    MUH and House of Cards Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & % ...

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

  7. Gym100947E || codeforces 559c 组合数取模

    E - Qwerty78 Trip Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u S ...

  8. Codeforces Round #281 (Div. 2)

    题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football gam ...

  9. CodeForces 512B(区间dp)

    D - Fox And Jumping Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. 2018年5月20日--西安icpc邀请赛试题一览

    热身赛 正式赛 A题,样例不代表后台数据,出题人把题意和后台数据代表的意思搞差了! B: C: D-E F f-G G G-H H-I I-J J-k K-2

  2. 分享一个我改进过的ocr算法

    https://github.com/zhangbo2008/chineseOCR-jingjianban 欢迎大家前来拍砖

  3. [Google Guava] 排序: Guava强大的”流畅风格比较器”

    原文链接 译者: 沈义扬 排序器[Ordering]是Guava流畅风格比较器[Comparator]的实现,它可以用来为构建复杂的比较器,以完成集合排序的功能. 从实现上说,Ordering实例就是 ...

  4. 2、细节&Class对象

    2.细节&Class对象 class Class{ 提供获取字节码文件中的内容. 比如: 名称,字段,构造函数,一般函数 } 该类就可以获取字节码文件中的所有内容,那么反射就是依靠该类完成的. ...

  5. js字符串字母大小写转换

    toLocaleUpperCase 方法 返回一个字符串,其中所有的字母字符都被转换为大写,同时适应宿主环境的当前区域设置. stringVar.tolocaleUpperCase( )必选的 str ...

  6. Gradle 如何配置将编译的 JAR 发布到 Archiva 中

    有时候我们希望将我们的jar 开发包发布到 Archiva 中. 如何配置 Gradle 的编译脚本呢? 首先你需要启用 Gradle 的 Maven-publish 插件. plugins { id ...

  7. [Luogu] 矩形覆盖

    https://www.luogu.org/problemnew/show/P1034 数据太水 爆搜过掉 #include <iostream> #include <cstdio& ...

  8. 欧几里得?x

    可以去看dalao博客 orz 1.欧几里得算法 带余除法定理:a,b∈Z,其中b>0,存在唯一q及r,使a=bq+r,其中0<=r<b; 辗转相除法(欧几里得算法)依据:(a,b) ...

  9. 数据结构实验之二叉树七:叶子问题(SDUT 3346)

    #include <bits/stdc++.h> using namespace std; struct node { char data; struct node *lc, *rc; } ...

  10. Linux之基础命令

    常用命令 查看ip地址的两种方式 ifconfig ip addr show Linux的两种ip地址: 127.0.0.1 本机回环地址 0.0.0.0 全网地址/绑定所有网卡/所有地址 Linux ...