Problem "TLG"

begginer
c-plus-plus
c-plus-plus-14
problem
program
tlg
wrong-answer

#1

What is the Problem in this Program?
i will run on my desktop it’s run Perfectly when i upload this same program on codechef that make error “Wrong Answer” why??

#include
using namespace std;
int main(){
long t, i;
cin>>t;
long a[t], b[t], winPlayer[t],lead[t], finalLead = 0, temp = 0;
for(i=0; i < t; i++)
{
cin>>a*>>b*;
}
for(i=0;i<t;i++)
{
if(a*>b*)
{
lead* = a* - b*;
winPlayer* = 1;
}
else if( b* > a* ){
lead* = b* - a*;
winPlayer* = 2;
}
}
finalLead = lead[0];
for( i = 1; i < t; i++){
if( finalLead < lead* ){
finalLead = lead*;
temp = i;
}
}
cout<<winPlayer[temp] <<" "<<finalLead;
return 0;
}


#2

yep, after checking your code thoroughly you are misunderstanding the question, definitely... ok so it goes, like this, for example first round : player 1 : 20 player 2 : 30 second round : player 1 : 40 player 2 : 10 so, in order to count the lead you, add score from the previous round to the current round, so first round : player 1 : 20 player 2 : 30 second round : player 1 : 60 //because 40 + 20 player 2 : 40 //because 30 + 10 so, let's find out the lead, in first round, player 2 leads by 10, in second round, player 1 leads by 20, so following the rules that the one with the highest lead wins, player 1 wins in round two, with lead of 20


#3

ok, just a short comment, if you select your code and ctrl+k it, it is going to be formatted as code


#4

Please at least TRY searching the forum.