RRSTONE - Editorial

can someone tell me why this solution is giving WA? https://www.codechef.com/viewsolution/15554047 Thanks for the help in advance.

can somebody pls look at my code and tell why it is giving wrong answer
link: https://www.codechef.com/viewsolution/18766313

can somebody pls look at my code and tell why it is giving wrong answer
link: https://www.codechef.com/viewsolution/18766313

I have used long int only and the solution is absolutely fine…don`t forget to add the corner case when number of turns(k) == 0

#include<stdio.h>
#include<limits.h>

#define s(a) scanf("%ld",&a)
#define max(a,b) a >= b ? a : b
#define min(a,b) a <= b ? a : b
#define S 102400
typedef long int li;

int main()
{

li k,n,arr[S],i,min_no = INT_MAX, max_no = 0;

s(n); s(k);

for(i=0; i<n; i++){
	s(arr[i]);
	
	min_no = min(min_no,arr[i]);
	max_no = max(max_no,arr[i]);
}

if(k == 0){
	for(i=0; i<n; i++)
		printf("%ld ",arr[i]);
}
else if( k % 2==0){
	for(i=0; i<n; i++)
		printf("%ld ",arr[i] - min_no);
}
else{
	for(i=0; i<n; i++)
		printf("%ld ",max_no - arr[i]);
}

return 0;

}

Can Anyone tell me why it is giving wa?

https://www.codechef.com/viewsolution/19350552

Solution in C++, you just need 2 little lines:

long long max = *max_element(A.begin(), A.end());
transform(A.begin(), A.end(), A.begin(), bind1st(minus(), max));

Full solution can be viewed here.

Hope that helps!