Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

RRSTONE ERROR EVEN THOUGH THE CODE IS CORRECT!

$
0
0

SEE my code for RRSTONE,Its working very well but why codechef is showing wrong result!!!

include<stdio.h>

include<stdlib.h>

int main() { long int n,k; long int max=0,i=0,j=0; scanf("%ld%ld",&n,&k); long int A=(long int )calloc(n,sizeof(int)); while(i<n) { scanf("%ld",&A[i]); i++; } x: i=0; max=A[i]; while(i<n) {

if(max<A[i])
{
    max=A[i];
    i++;        
}else {
max=max;
i++;
}
}       
i=0;

if(k!=0)
{j=0;
while(j<n)
{
A[j]=max-A[j];
j++;
}if(k%2==0)
    {
    k++;
    goto x;
    }
} else{ goto r;
}

r:
j=0;
while(j<n)
{
printf("%ld ",A[j]);
j++;
}return(0);
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>