 Why I'm getting WA with this code on The Lead Game problem ????

#include <stdio.h>
#include <math.h>
int main(void) {
int n,i=0,max,winner;
scanf("%d",&n);
int S[n],T[n],R[n],L[n];
while(n–){
scanf("%d",&S*); scanf("%d",&T*);
L* = abs(S*-T*);
if (S*>T*)
R*=1;
else
R*=2;
i++;
}
max = L;
winner = R;
for (i=1;i<n;++i){
if (L*>max)
max = L*;
winner = R*;
}
printf("%d %d",winner,max);
return 0;
}

http://www.codechef.com/viewsolution/6764394 TAKE A LOOK AT MY SOLUTION

OK I need the karma.
Here is an accepted version of your code,
http://www.codechef.com/viewsolution/6988064

There are three primary errors which I will point out.

int S[n],T[n]

You don’t need to store the values why use array.

Simply replace this with

int S,T;

**scanf("%d",&S*); scanf("%d",&T*);**
The scores are cumulative, read the question again. Score of the previous round questions get carried forward. Replace this with,

int a,b;
scanf("%d",&a); scanf("%d",&b);
S=S+a;
T=T+b;

**while(n--)**
You are reducing the value of n here to 0, how do you expect the next for loop to work,
for (i=1;i<**n**;++i)

**if (L*>max)
max = L*;
winner = R*;
**

You missed a bracket here. Without it winner is always getting set to the R[n-1]

if (L>max){

max = L
;

winner = R*;
}**

Hope this helps.

So, where is the fault of my code ??? I don’t see any of it. Just a different way to solve the problem