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

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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章