×

# The Lead Game not working.Help.

 0 include int cmp (int a,int b) { return ((int)a-(int)b); } int main(void) { int t,a,b,c,e,f,g,h; scanf ("%d",&t); int d [t][2],i [t][2],j [t]; for (c=0;c 1000 || b>1000) { abort (); } d [c][0]=a;d [c][1]=b;i [c][0]=0;i [c][1]=0; i [c][0]=i [c][0]+d [c][0]; i [c][1]=i [c][1]+d [c][1]; } for (c=0;c h) { printf ("1 %d",g); } else if (g==0 && f==0) { abort (); } else { printf ("2 %d",h); } return 0;  } Why am i getting Wrong Answer.Please help. asked 26 Jul, 11:48 8●3 accept rate: 0%

 0 hi kriskhundu , if u can generate a url of your code on ideone then it would be helpful for us to debug answered 26 Jul, 13:12 0●1 accept rate: 0%
 0 The question asks you to find the max lead on the basis of total score till a round. And, the total score of a round is the cumulative sum of all the scores till that round, including it. Looking at your code, it seems like you are storing the cumulative score in the array $i[t][2]$. But there's a problem in the implementation. Change this  i [c][0] = i [c][0] + d [c][0]; i [c][1] = i [c][1] + d [c][1];  To this  i [c][0] = i [c-1][0] + d [c][0]; i [c][1] = i [c-1][1] + d [c][1];  Also, take care of the case when $c = 0$ ($c-1$ will be $-1$ in that case), and then your code will be fine. The reason that your code gives a right answer in the sample test case is that the max lead in it happens in the first round itself, so there is no need of a cumulative score. But this may not happen always, giving a wrong answer in the other cases. answered 26 Jul, 13:58 1.0k●4 accept rate: 13% 1 Thank you Mr Lifesaver :) (26 Jul, 21:26) Well, you can show your gratitude by accepting the answer. (26 Jul, 22:26)
 0 r=[] s=[] for t in range(int(input())): a,b=map(int,raw_input().split()) if a>b: c=a-b r.append(c) s.append(1) elif b>a: c=b-a r.append(c) s.append(2) e=[list(l) for l in zip(r,s)] print e q=max(e) print q[1],q[0]  my code for lead game in python.. wrong answer help needed. answered 11 Aug, 00:12 0★sabi_91 1●1 accept rate: 0%
 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:

×1,980
×27
×1