该题难点在于求最小的离开数,最大的没什么好说的,关键是求最小的。

可以这样去想,最小的离开数就是每个人获得的牌数等于他所能接受的最大牌数-1,这样就可以直接比较m=a1(k1-1)+a2(k2-1)与n的大小,n-m即为最小的离开数。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
int a1, a2, k1, k2, n;
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
scanf("%d %d %d %d %d", &a1, &a2, &k1, &k2, &n);
int m = a1 * (k1 - 1) + a2 * (k2 - 1);
if(n <= m)
printf("0");
else
printf("%d", n - m);
int cnt = 0, res = n;
if(k1 > k2)
{
cnt = n / k2;
if(cnt > a2)
{
cnt = a2;
res -= cnt * k2;
}
else
res -= cnt * k2;
cnt += res / k1;
}
else
{
cnt = n / k1;
if(cnt > a1)
{
cnt = a1;
res -= cnt * k1;
}
else
res -= cnt * k1;
cnt += res / k2;
}
printf(" %d\n", cnt);
}

【Yellow Cards CodeForces - 1215A 】【贪心】的更多相关文章

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

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

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

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

  3. [C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces

    1 Problem Description Problem The final match of the Berland Football Cup has been held recently. Th ...

  4. CodeForces - 893D 贪心

    http://codeforces.com/problemset/problem/893/D 题意 Recenlty Luba有一张信用卡可用,一开始金额为0,每天早上可以去充任意数量的钱.到了晚上, ...

  5. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  6. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 828D) - 贪心

    Arkady needs your help again! This time he decided to build his own high-speed Internet exchange poi ...

  7. CodeForces - 93B(贪心+vector<pair<int,double> >+double 的精度操作

    题目链接:http://codeforces.com/problemset/problem/93/B B. End of Exams time limit per test 1 second memo ...

  8. C - Ordering Pizza CodeForces - 867C 贪心 经典

    C - Ordering Pizza CodeForces - 867C C - Ordering Pizza 这个是最难的,一个贪心,很经典,但是我不会,早训结束看了题解才知道怎么贪心的. 这个是先 ...

  9. Codeforces 570C 贪心

    题目:http://codeforces.com/contest/570/problem/C 题意:给你一个字符串,由‘.’和小写字母组成.把两个相邻的‘.’替换成一个‘.’,算一次变换.现在给你一些 ...

随机推荐

  1. apply() 函数家族介绍

    apply() 函数算是R语言中很基础的一个函数,同时还有 sapply()  lapply()  tapply() 函数精简了 apply() 函数的用法. apply() 函数是一个很R语言的函数 ...

  2. 【IntelliJ IDEA学习之二】IntelliJ IDEA常用配置

    版本:IntelliJIDEA2018.1.4 一.常用配置两张概览图(1)工作区总览介绍图 (2)setting配置图 --------------------------------------- ...

  3. Xilinx FGPA 上板调试 集成逻辑分析工具 Integrated Logic Analyzer(ILA) 简单配置 chipscope

    Xilinx Vivado 提供了上板后的FPGA逻辑分析,信号视图显示等功能. 需要注意,上板后查看信号需要重新综合,并且需要耗费一定的片上布局布线资源. 1. 添加debug信号 可以对模块端口或 ...

  4. 读《PMI 分析手册》

    目录 读<PMI 分析手册> 官方 PMI 基本概况 官方制造业 PMI 官方非制造业 PMI 综合 PMI 产出指数 PMI 分析框架 PMI 与经济周期 官方 PMI 分析 参考研报 ...

  5. Python下的XML-RPC客户端和服务端实现(基于xmlrpclib SimpleXMLRPCServer 模块)

    RPC是Remote Procedure Call的缩写,翻译成中文就是远程方法调用,是一种在本地的机器上调用远端机器上的一个过程(方法)的技术,这个过程也被大家称为“分布式计算”,是为了提高各个分立 ...

  6. 关于linux 执行权限的理解

    关于linux 执行权限的理解他这个执行权限不是 执行什么命令的 是这个文件 是否能被执行的权限 比方说<pre>shell_exec('/home/crontabtest12.sh'); ...

  7. mapReduce 大数据离线分析

    数据分析一般分为两种,一种是在线一种是离线 流程: 一般都是对于日志文件的采集和分析 场景实例(某个电商网站产生的用户访问日志(access.log)进行离线处理与分析的过程) 1.需求: 基于Map ...

  8. SSL密钥协商过程分析

    一.说明 尽管做过证书生成.双向认证.SSL通信编程等事情,但一直不清楚SSL如何完成密钥交换.看网上的资料则众说纷纭,最近和朋友学习时聊到了这个问题,然后正巧上周处理客户反馈SSL版本过低时领导也想 ...

  9. Vim 入门教程

    Vim 入门教程 转载请保留以上信息 Vim 的教程相对比较零散,系统的教程比较少,我也阅读过不少教程,走过很 多弯路.借着 Vim-china 组织组建这一契机,整理下自己学习过的内容, 分享给大家 ...

  10. Git flow 工作流与规范

    概述 简版图: PS. 可能用到的命令: 1.从指定 commit拉出新分支   git checkout commitId -b 本地新branchName git checkout 9fbc3d0 ...