-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path1574B
129 lines (124 loc) · 2.63 KB
/
1574B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//Question link: https://codeforces.com/problemset/problem/1574/B
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i, n) for (int i = 0; i < n; i++)
#define rl(i, m, n) for (int i = n; i >= m; i--)
#define py cout << "YES\n";
#define pn cout << "NO\n";
#define pi 3.141592653589793238
#define vr(v) v.begin(), v.end()
#define rv(v) v.end(), v.begin()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Asquare cout.tie(NULL);
using namespace std;
ll gcd(ll a, ll b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b) * b); }
bool sorta(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
bool sortd(const pair<int, int> &a, const pair<int, int> &b) { return (a.second > b.second); }
void printarr(ll arr[], ll n)
{
fl(i, n) cout << arr[i] << " ";
cout << "\n";
}
string decToBinary(int n)
{
string s = "";
int i = 0;
while (n > 0)
{
s = to_string(n % 2) + s;
n = n / 2;
i++;
}
return s;
}
ll binaryToDecimal(string n)
{
string num = n;
ll dec_value = 0;
int base = 1;
int len = num.length();
for (int i = len - 1; i >= 0; i--)
{
if (num[i] == '1')
dec_value += base;
base = base * 2;
}
return dec_value;
}
bool isPrime(int n)
{
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
bool isPowerOfTwo(int n)
{
if (n == 0)
return false;
return (ceil(log2(n)) == floor(log2(n)));
}
//Code by Abhinav Awasthi
//Language C++
//Practice->Success
int binarySearch(ll arr[], ll l, ll r, ll x)
{
while (l <= r)
{
int m = l + (r - l) / 2;
// Check if x is present at mid
if (arr[m] == x)
return m;
// If x greater, ignore left half
if (arr[m] < x)
l = m + 1;
// If x is smaller, ignore right half
else
r = m - 1;
}
// if we reach here, then element was
// not present
return -1;
}
void asquare()
{
ll a,b,c,m;
cin>>a>>b>>c>>m;
ll arr[3]={a,b,c};
sort(arr,arr+3);
ll mx=a+b+c-3;
ll mn=arr[2]-arr[1]-arr[0]-1;
if(m>=mn&&m<=mx)
py
else pn
}
int main()
{
Code By Asquare
ll t;
cin>>t;
fl(iiii,t)
{
asquare();
}
return 0;
}