codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
来源:互联网 发布:weka apriori算法 编辑:程序博客网 时间:2024/06/08 05:48
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.
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.
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
8 6 4 5
YES
8 6 4 6
NO
10 3 11 4
NO
4 2 1 4
YES
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.
贪心~
(其实我也不知道是什么~)
没有用的情况就是在做烤箱的时候已经烤完所有蛋糕,或者做完烤箱之后只要再一阶段时间就能烤完所有蛋糕,直接计算判断一下就可以了~
#include<cstdio>#include<iostream>using namespace std;int n,t,k,d;int main(){scanf("%d%d%d%d",&n,&t,&k,&d);int yuan=(n+k-1)/k,now=d/t;yuan-=now;if(yuan<=1) puts("NO");else puts("YES");}
- Codeforces Round #413 Div. 1 + Div. 2 A. Carrot Cakes
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A. Carrot Cakes
- Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot+【等腰三角形等比例缩小】
- (Codeforces Round #413, rated, Div. 1 + Div. 2)(A+B)
- Codeforces 799A Carrot Cakes 题解
- Codeforces Round #413(Div. 1 + Div. 2)
- Codeforces Round #230 (Div. 2) C / (Div. 1) A
- codeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)A题
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A题
- Codeforces Round #167 (Div. 2 && Div.1)
- Codeforces Round #185 (Div. 1) && (Div. 2)
- Codeforces Round #166 (Div. 1) && (Div. 2)
- Codeforces Round #292 (Div. 2 Div. 1)
- A. Carrot Cakes Codeforce 思维
- Codeforces Round #413 Div. 1 + Div. 2 C. Fountains
- codeforces Round #413 Div. 1 + Div. 2 C Fountains
- setTextColor六种方式
- Java面向对象编程知识点归纳
- PHP关于Braintree支付
- 针对苹果充值的坏账的防范方法
- android Data Binding Library
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- 本周的博客----第12周
- MyBatis批量插入返回主键
- django连接mysql
- mini2440通过dnw下载linux虚拟机的程序
- 开发简单的CMS
- codeforces Round #413 Div. 1 + Div. 2 C Fountains
- JAVA递归
- 快速自定义漂亮的Dialog