×

# 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 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