はまやんはまやんはまやん

hamayanhamayan's blog

ジャンプ [PG BATTLE 2019 ましゅまろ A]

https://products.sint.co.jp/hubfs/resource/topsic/pgb/1-1.pdf

解説

入力例で正しいことしか確認できていません!落ちる可能性ありますので、ご注意ください

公式解説

向こう岸までジャンプできる条件は「こちら側から中洲へジャンプできる」かつ「中洲から向こう岸までジャンプできる」ということ。
ジャンプできるかの判定は距離≦Dであることである。
条件式をうまくつかうことで回答できる。

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/

int W, K, D;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> W >> K >> D;

    bool firstJump = K <= D;
    bool secondJump = (W - K) <= D;

    if (firstJump and secondJump) cout << "Yes" << endl;
    else cout << "No" << endl;
}