Submission #1413391


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
#define NO "NO"
#define YES "YES"
typedef long long ll;
//---------------------------------------------------------------------------------------------------
ll N, A, B, C, D;
string solve() {
    ll d = abs(A - B);
 
    ll i = 0LL;
    while (i * 2LL <= N - 1LL) {
        ll ma = D * (N - 1LL - i * 2LL);
        ll mi = C * (N - 1LL - i * 2LL);
 
        ll mma = abs(C - D) * i;
 
        if (mi - mma <= d && d <= ma + mma) return YES;
 
        i++;
    }
    return NO;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> A >> B >> C >> D;
    cout << solve() << endl;
}

Submission Info

Submission Time
Task B - Moderate Differences
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1593 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 38
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt, sample4.txt
All sample1.txt, sample2.txt, sample3.txt, sample4.txt, a01.txt, a02.txt, a03.txt, a04.txt, b01.txt, b02.txt, b03.txt, b04.txt, c01.txt, c02.txt, c03.txt, c04.txt, d01.txt, d02.txt, d03.txt, d04.txt, d05.txt, d06.txt, d07.txt, d08.txt, d09.txt, d10.txt, d11.txt, d12.txt, d13.txt, d14.txt, d15.txt, d16.txt, d17.txt, d18.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
a01.txt AC 1 ms 256 KB
a02.txt AC 1 ms 256 KB
a03.txt AC 1 ms 256 KB
a04.txt AC 1 ms 256 KB
b01.txt AC 1 ms 256 KB
b02.txt AC 1 ms 256 KB
b03.txt AC 1 ms 256 KB
b04.txt AC 1 ms 256 KB
c01.txt AC 1 ms 256 KB
c02.txt AC 1 ms 256 KB
c03.txt AC 1 ms 256 KB
c04.txt AC 1 ms 256 KB
d01.txt AC 1 ms 256 KB
d02.txt AC 1 ms 256 KB
d03.txt AC 1 ms 256 KB
d04.txt AC 1 ms 256 KB
d05.txt AC 1 ms 256 KB
d06.txt AC 1 ms 256 KB
d07.txt AC 1 ms 256 KB
d08.txt AC 1 ms 256 KB
d09.txt AC 1 ms 256 KB
d10.txt AC 1 ms 256 KB
d11.txt AC 1 ms 256 KB
d12.txt AC 1 ms 256 KB
d13.txt AC 1 ms 256 KB
d14.txt AC 1 ms 256 KB
d15.txt AC 1 ms 256 KB
d16.txt AC 1 ms 256 KB
d17.txt AC 1 ms 256 KB
d18.txt AC 1 ms 256 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB
sample4.txt AC 1 ms 256 KB