×

# Help me debugging TLG

 0 why am I getting the wrong answer although my output is correct?! here's the Q:https://www.codechef.com/problems/TLG my code(c): #include #include int r; int main() { scanf("%d",&r); int sc[r][4],i,max1=0,max2=0; for(i=0;isc[i][1]) { sc[i][2]=(sc[i][0]-sc[i][1]); sc[i][3]=0;} else { sc[i][3]=(sc[i][1]-sc[i][0]); sc[i][2]=0;} } max1=sc[0][2]; max2=sc[0][3]; for (i=0;imax1) { max1=sc[i][2]; } if(sc[i][3]>max2) { max2=sc[i][3]; } } if(max1>max2) {printf("\n%d",1);printf(" %d",max1);} else {printf("\n%d",2);printf(" %d",max2);} return 0; }  asked 14 Jun '17, 02:51 1 accept rate: 0% 15.2k●1●18●59

 0 Look at the table in the question carefully!! Lead in each round is the CUMULATIVE sum of leads of that round and leads of previous round. Meaning, lead is to be taken from TOTAL SCORE instead of that particular round's score. Look here-  Round Player 1(TOTAL SCORE) Player 2(Total score) Winner Lead 1 140 82 Player 1 58 2 229 216 Player 1 13 3 319 326 Player 2 7 4 431 432 Player 2 1 5 519 522 Player 2 3  Look at the lead calculation. It is not the lead obtained from that round, but sum of lead of previous round+sum of lead of that round. I advise looking at the 2 tables given in Q again. Hope this helps ^^ answered 14 Jun '17, 10:37 15.2k●1●18●59 accept rate: 18%
 0 what u have done is took d differrence of scores in each round and calculate d max.differrence printed accordingly.....bt what actually u have to do is to take d difference of a particular round by calculating score till dat round for both players and then u should take d differrence...and find the max.diff and print accordingly...i have modified ur code and also submited jst now which gave me an AC .....here is ur modified code : https://www.codechef.com/viewsolution/14251106 !! hope dis clears ur doubt !! happy coding :) answered 14 Jun '17, 12:04 1★msd_007 317●8 accept rate: 5%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,698
×1,056
×123

question asked: 14 Jun '17, 02:51

question was seen: 324 times

last updated: 14 Jun '17, 12:04