Skip to content

Commit a497157

Browse files
authored
Create (HACKEREARTH)the_score_game.cpp
1 parent 4061208 commit a497157

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
typedef vector<int>vt;
5+
typedef pair<int,int>pr;
6+
#define fo(i,a,b) for(int i=a; i<=b; i++)
7+
int main()
8+
{
9+
ios::sync_with_stdio(0);
10+
cin.tie(0);
11+
ll t;
12+
cin>>t;
13+
while(t--)
14+
{
15+
ll n,i;
16+
cin>>n;
17+
ll a[n],b[n];
18+
ll r=0,s=0;
19+
vector<int>vt;
20+
for(i=0;i<n;i++)
21+
{
22+
cin>>a[i];
23+
r+=a[i];
24+
}
25+
for(i=0;i<n;i++)
26+
{
27+
cin>>b[i];
28+
vt.push_back(2*a[i]+b[i]);
29+
}
30+
ll c=0;
31+
sort(vt.rbegin(),vt.rend());
32+
while(s<=r)
33+
{
34+
s+=vt[c];
35+
c++;
36+
}
37+
cout<<c<<endl;
38+
}
39+
}

0 commit comments

Comments
 (0)