Codeforces Round #413 Div. 1 + Div. 2 A. Carrot Cakes

来源:互联网 发布:手机 Ubuntu 编辑:程序博客网 时间:2024/06/08 10:54

Codeforces Round #413 Div. 1 + Div. 2 A. Carrot Cakes
A. Carrot Cakes
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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”.

Examples
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

题解 :
先算出第一台所需要的总时间
然后计算第二台 产生并且做出一次 的总时间

#include <stdio.h>#include <bits/stdc++.h>using namespace std;int n,t,k,d;int main(){    cin>>n>>t>>k>>d;    int p1=n/k+(n%k==0?0:1);    p1*=t;     int p2=d+t;    if(p2<p1) cout<<"YES";    else cout<<"NO";    return 0;}
0 0