Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A题

其实这个题就是考虑 某一炉烧烤的始末时间可能会跨越第二个炉形成的时间,
那么就要考虑 是烤完这一炉再用新炉还是不烤等新炉好了再用,,
我是分情况讨论的,看了拖爷的代码感觉神奇的不行

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <ctype.h>
#include <vector>
#include <algorithm>
// cout << "  ===  " << endl;

using namespace std;
typedef long long ll;
const int maxn = 200 + 7, INF = 0x3f3f3f3f, mod = 1e9+7;
int n, t, k, d;

int main() {

    scanf("%d %d %d %d", &n, &t, &k, &d);
    int cnt = n / k;
    if(n % k != 0) cnt++; 
    int ans1 = cnt * t;   

    int tt = 0;
    int n1 = d / t;
    int n2 = d / t + (d % t == 0 ? 0 : 1);

    int ans2 = ((cnt-n1) / 2 + ((cnt-n1) % 2 == 1 ? 1 : 0)) * t +d;
    int ans3 = n2 * t + ((cnt-n2) / 2 + ((cnt-n2) % 2 == 1 ? 1 : 0)) * t;

    if(ans2 < ans1 || ans3 < ans1) puts("YES");
    else puts("NO");

    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值