This post was flagged by the community and is temporarily hidden.

Will post its solution once test time gets over.

@ayanujju I couldnât solve the âqueries on expressionâ problem. Were you able to solve both the problems? Will they only call those who have solved both?

can you post it now?

Yes. I donât know what will be the eligibility criteria but as per the trend, it seems like theyâll be selecting only those candidates who solved both.

Sure. Here you go.

#include <bits/stdc++.h>

using namespace std;

#define ll long long

class Pair {

public:

ll a,b;

Pair(ll a, ll b)

: a(a), b(b)

{

}

};

bool operator<(const Pair& p1, const Pair& p2)

{

return p2.a*(p2.b-p2.b/2)>p1.a*(p1.b-p1.b/2);

}

void fun(ll a[],ll b[],int n,ll k)

{

int i,j;

ll s=0,s1;

priority_queue Q,Q1;

for(i=0;i<n;i++)

{

s+=a[i]*b[i];
Q.push(Pair(a[i],b[i]));
Q1.push(Pair(b[i],a[i]));
}
s1=s;
j=0;
while(s>k)
{
Pair p=Q.top();
s-=p.a*(p.b-p.b/2);

p.b/=2;

Q.pop();

Q.pushÂ§;

j++;

}

i=0;

while(s1>k)

{

Pair p=Q1.top();

s1-=p.a*(p.b-p.b/2);

p.b/=2;

Q1.pop();

Q1.pushÂ§;

i++;

}

if(i>j)

cout<<âAlice\nâ;

else if(i<j)

cout<<âBob\nâ;

else

cout<<âTie\nâ;

}

int main()

{

int t,n,i;

ll a[100001],b[100001],k;

cin>>t;

while(tâ)

{

cin>>n;

for(i=0;i<n;i++)

cin>>a[i];

for(i=0;i<n;i++)

cin>>b[i];

cin>>k;

fun(a,b,n,k);

}

return 0;

}