Skip to content

Commit 94239bf

Browse files
authored
Create BENCHP.cpp
1 parent 0792232 commit 94239bf

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

Codechef solutions/BENCHP.cpp

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
#define bug cout<<" *H* ";
4+
#define nxtl cout<<"\n";
5+
//fors
6+
#define loop(i,b) for(ll i=0;i<b;i++)
7+
#define rloop(i,b) for(ll i=b;i>=0;i--) //from [b to 0]
8+
#define arin(ar) loop(i,sizeof(ar)/sizeof(ar[0])) cin>>ar[i];
9+
#define show(ar) loop(i,sizeof(ar)/sizeof(ar[0])) cout<<ar[i]<<" ";
10+
#define For(i,a,b) for (ll i = a;(a<b)?i<b:i>=b;(a<b)?i++:i--)//from [a to b)or[b to a]
11+
//Data Types
12+
#define ll long long
13+
#define ulli unsigned long long ll
14+
#define rt5 pow(5,0.5)
15+
#define fib(n) (pow((1+rt5),n)-pow((1-rt5),n))/(pow(2,n)*rt5)
16+
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
17+
#define mod 1000000007
18+
#define INF 1000000008
19+
//Bits
20+
#define clz(n) __builtin_clz(n)
21+
#define ones(n) __builtin_popcount(n)
22+
#define parity(n) __builtin_parity(n)
23+
#define ctz(n) __builtin_ctz(n)
24+
//Vector
25+
#define vec(v) vector<ll> v
26+
#define pb(a) push_back(a)
27+
#define pii pair<ll,ll>
28+
#define pbp(a,b) push_back({a,b})
29+
#define all(a) (a.begin(),a.end())
30+
#define fs first
31+
#define sc second
32+
//Google
33+
#define Case cout<<"Case #"<<cs++<<": ";
34+
//Output
35+
#define out(k) if(k) cout<<"Yes\n"; else cout<<"No\n";
36+
//*** USEFUL FUNCTIONS ***
37+
// GCD of a & b
38+
ll gcd(ll a, ll b)
39+
{if (b == 0) return a;
40+
return gcd(b, a % b);}
41+
// LCM of a & b
42+
ll lcm(ll a, ll b)
43+
{return (a / gcd(a, b)) * b;}
44+
// MODULO of a * b
45+
ll modulo(long long a, long long b){
46+
a=a*b;
47+
while(a>=mod) a-=mod;
48+
return a;
49+
}// Calculates (x^n) % m in O(logN)
50+
ll modpow(ll x, ll n, ll m) {
51+
if (n == 0) return 1%m;
52+
long long u = modpow(x,n/2,m);
53+
u = (u*u)%m;
54+
if (n%2 == 1) u = (u*x)%m;
55+
return u;
56+
}
57+
bool flag=true;
58+
ll cs=1;
59+
main()
60+
{
61+
fast
62+
ll t;
63+
cin>>t;
64+
while(t--)
65+
{
66+
ll n,rq,w;
67+
cin>>n>>rq>>w;
68+
map<ll,ll> mp;
69+
loop(i,n){
70+
ll a;
71+
cin>>a;
72+
mp[a]++;
73+
}
74+
bool flg=false;
75+
if(w>=rq){
76+
flg=true;
77+
}
78+
else{
79+
ll sum=w;
80+
for(auto it : mp){
81+
if(it.second > 1){
82+
sum+=(it.second - it.second % 2) *it.first;
83+
}
84+
if(rq<=sum){
85+
flg=true;
86+
break;
87+
}
88+
}
89+
}
90+
out(flg);
91+
}
92+
cerr<<"time taken: "<<(float)clock()/CLOCKS_PER_SEC<<endl;
93+
}

0 commit comments

Comments
 (0)