CodeChef: Practical coding for everyone I need help in this. It is showing wrong answer.
I saw your code its quiet more complicated since you are trying to store the inputs while you may see my approach also
CODE:
#include
using namespace std;
int main()
{
int n,si,ti,lead,w,win;
w=0;
win=0;
si=0;ti=0;
cin>>n;
while(n–)
{
int s,t;
cin>>s>>t;
si=si+s;
ti=ti+t;
if(si>ti)
{
lead=si-ti;
}
else
{
lead=ti-si;
}
if(win<lead)
{
win=lead;
if(si>ti)
w=1;
else
w=2;
}
}
cout<<w<<" "<<win;
}
hope this may help.
2 Likes
The same mistake everyone seems to make. It’s the maximum difference in cumulative scores.
2 Likes
Did you really just link a link to a link to a link to your answer?
3 Likes
I’m trying to break the forum software
3 Likes
Thanks everyone… I got that!!