A. Carrot Cakes
time limit per test  

1 second

memory limit per test  

256 megabytes

 

In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.

Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.

Input

The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.

Output

If it is reasonable to build the second oven, print "YES". Otherwise print "NO".

 
input
8 6 4 5
output
YES
input
8 6 4 6
output
NO
input
10 3 11 4
output
NO
input
4 2 1 4
output
YES
Note:

In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.

In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.

In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.

题目大意:

     有一个面包机每t分钟可以完成一次任务,每次任务可以制作k个蛋糕。

     现在有n个蛋糕需要被制作,为了提高效率他可以在花费d分钟再制作一个面包机

     在制作新机器的同时,旧机器依旧可以运作。新机器制作完成之后两台机器可以同时运转

     他最多可以制作一台新面包机。

     问重新制作一台面包机能否提高效率? 可以 YES 、 否NO

解题思路:

     大致思路就是分别计算出制作一台新机器完成任务所花费的总时间和只使用旧机器完成任务的总时间,然后比较。

     因为在制作新机器的同时,旧机器依旧可以运转,因为不好判断到底是新机器完成最后一次任务

     还是旧机器完成最后一次任务。所以分两种情况计算,找出最优情况(即花费时间最少的)

AC代码:

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define ll long long using namespace std; int main ()
{
int n,t,k,d;
int i,a,j;
while (scanf("%d %d %d %d",&n,&t,&k,&d)!=EOF)
{
if (k >= n){ // 新机器建造完成之前 蛋糕就能全部完成
printf("NO\n"); continue;
}
int len = (n+k-)/k;
i = d/t; // 建造新机器的过程中旧机器完成了几次任务(包括正在完成的)
if (i == ) i == ; // 正在完成的
if (d%t) i ++; j = len - i; // 还剩余几次任务
a = min(max(i*t+t*(j/),d+t*(j-j/)),max(i*t+t*(j-j/),d+t*(j*))); // 有可能是新机器最后完成 也有可能是旧机器最后完成 if (a >= len*t)
printf("NO\n");
else
printf("YES\n");
}
return ;
}

思路比较麻烦,仅供参考哈!

Codeforces Round #413 A. Carrot Cakes的更多相关文章

  1. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)(A.暴力,B.优先队列,C.dp乱搞)

    A. Carrot Cakes time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  2. Codeforces Round#413 Div.2

    A. Carrot Cakes 题面 In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, al ...

  3. Codeforces Round#413 Problem A - C

    Problem#A Carrot Cakes vjudge链接[here] (偷个懒,cf链接就不给了) 题目大意是说,烤面包,给出一段时间内可以考的面包数,建第二个炉子的时间,需要达到的面包数,问建 ...

  4. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) 一夜回到小学生

    我从来没想过自己可以被支配的这么惨,大神讲这个场不容易掉分的啊 A. Carrot Cakes time limit per test 1 second memory limit per test 2 ...

  5. Codeforces Round #413(Div. 1 + Div. 2, combined)——ABCD

    题目在这里 A.Carrot Cakes 乱七八糟算出两个时间比较一下就行了 又臭又长仅供参考 #include <bits/stdc++.h> #define rep(i, j, k) ...

  6. Codeforces Round #542 B Two Cakes

    B. Two Cakes time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. Codeforces Round #413, rated, Div. 1 + Div. 2 C. Fountains(贪心 or 树状数组)

    http://codeforces.com/contest/799/problem/C 题意: 有n做花园,有人有c个硬币,d个钻石 (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100  ...

  8. C.Fountains(Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)+线段树+RMQ)

    题目链接:http://codeforces.com/contest/799/problem/C 题目: 题意: 给你n种喷泉的价格和漂亮值,这n种喷泉题目指定用钻石或现金支付(分别用D和C表示),C ...

  9. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains 【树状数组维护区间最大值】

    题目传送门:http://codeforces.com/contest/799/problem/C C. Fountains time limit per test 2 seconds memory ...

随机推荐

  1. java中的Lamdba表达式和Stream

    基于JDK 1.8 1.循环: // 以前的循环方式 for (String player : players) { System.out.print(player + "; ") ...

  2. [原创]SpringBoot上传图片踩的坑

    最近项目里面有个需求,要上传图片到阿里云的OSS服务.所以需要写个上传图片的接口给前端. 这个简单的接口本来就给分配了1个工时,感觉也蛮简单的.但编码过程中遇到了好几个问题,现在一一记录下来,避免再次 ...

  3. C#集合之集(set)

    包含不重复元素的集合称为“集(set)”..NET Framework包含两个集HashSet<T>和SortedSet<T>,它们都实现ISet<T>接口.Has ...

  4. 学习总结 —— python

    1.了解python 学习python 3 入门知识 python  库 .包  .模块 2.了解pycharm Pycharm 导入 Python 包.模块 pycharm 快捷键 3.了解djan ...

  5. redis 网络库文件 重构

    https://blog.csdn.net/yangbodong22011/article/details/65444273 相关博客 https://blog.csdn.net/tanswer_/a ...

  6. 高并发和多线程——Java内存模型

    个人理解: 1.并发编程分为三个核心:分工.同步.互斥 2.CPU.内存.I/O存在速度差异问题. 3.线程切换导致原子性问题.编译优化导致有序性问题.缓存导致可见性问题. 4.Java内存模型规范了 ...

  7. 如何使用新的glibc来编译自己的程序

    http://www.sysnote.org/2015/08/25/use-new-glibc/ 通常情况下我们都是直接使用glibc提供的一些库函数,但是某些特殊的情况,比如要修改glibc的一些代 ...

  8. 安装多个PHP环境会导致phpinfo和php -v中查看到的PHP版本不一致

    以前在上一个公司用的是集成环境wamp,PHP版本是5.5.后面换了一个公司,项目用的是PHP版本是5.2.今天想打开以前的项目想优化一下,发现pdo_mysql.dll扩展无法加载,于是想看看是不是 ...

  9. 【Lua】Lua + openresty遍历文件目录

    OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器,它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项. 今天用OpenRest ...

  10. 8086处理器的无条件转移指令——《x86汇编语言:从实模式到保护模式》读书笔记13

    本博文是对原书8.3.10的内容的总结. 一.相对短转移 指令格式是: jmp short 标号 标号也可以替换成具体的数值(标号和数值是等价的),例如 jmp short 0x2000 说明: (1 ...