Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

HackerEarth The Final Quiz problem solution

YASH PAL, 31 July 2024
In this HackerEarth The Final Quiz problem solution You, Bob, and Alice are playing a quizzing game. Throughout the game, you and the other two competitors have gained some points. Now at the end of the game, the three of you are given a final question. Before you hear the question you have to guess some special points.
If a contestant answers the question correctly he/she will be awarded the points equal to the special points he guessed and the same amount of points (he guessed ) will be deducted in case of a wrong answer. The participant who ends up with the highest score after the final question will end up winning the game.
Now it is time for you to guess your special points. You can bet any amount between 0 and your current score, both inclusive. You are given your current scoreX followed by the current scores of AliceY and BobZ. You are also given special points guessed by Alice A and special points guessed by Bob B. You have to guess your special points, which maximizes your probability of winning the Quiz.
You can assume that you and both the other participants each independently have a 50% chance to answer correctly. If multiple special points can give you the highest probability of winning, choose the minimum one.
HackerEarth The Final Quiz problem solution

HackerEarth The Final Quiz problem solution.

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--)
{
int a,a1,a2,b1,b2;
cin>>a>>a1>>a2>>b1>>b2;
assert(1<=a&&a<=100000);
assert(1<=a1&&a1<=100000);
assert(1<=a2&&a2<=100000);
assert(0<=b1&&b1<=a1);
assert(0<=b2&&b2<=a2);
int mi=-1;
int ans=1234567;
for(int i=0;i<=a;i++)
{
int x=a-i;
int y=a+i;
int x1=a1-b1;
int x2=a2-b2;
int y1=a1+b1;
int y2=a2+b2;
int c=0;
if(x>x1&&x>x2)
c++;
if(x>x1&&x>y2)
c++;
if(x>y1&&x>x2)
c++;
if(x>y1&&x>y2)
c++;
if(y>x1&&y>x2)
c++;
if(y>x1&&y>y2)
c++;
if(y>y1&&y>x2)
c++;
if(y>y1&&y>y2)
c++;
if(c>mi)
{
mi=c;
ans=i;
}
}
cout<<ans<<"n";
}
return 0;
}
coding problems solutions

Post navigation

Previous post
Next post

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes