! REALLY WRONG VERDICT GIVEN BY CODECHEF JUDGEMENT!

:coffin:RIP TO CODECHEF JUDGE :angel:

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		 Scanner sc=new Scanner(System.in);
         int t=sc.nextInt();
         while(t-->0)
         {
            int N=sc.nextInt();
            int K=sc.nextInt();
            int L=sc.nextInt();
            int arr[]=new int [N];
            for(int i=0;i<N;i++)
            {
                arr[i]=sc.nextInt();
            }
            Arrays.sort(arr);
            int sum=0,p=N-L;
            while(p>=0)
            {
                sum+=arr[p];
                p-=K;
            }
            System.out.println(sum);
         }
	}
}

:sneezing_face:

In the above :point_up_2: Solution of problem 3 in Div 4 from August Long(Contest Page | CodeChef),I got WA on Task 3 :weary:.

Submission Id:1017107875

It really upset me but after the contest was finished then I check for the submissions of other User I got this :point_down: :triumph:

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int T=sc.nextInt();
		while(T-->0){
		    int n=sc.nextInt();
		    int k=sc.nextInt();
		    int l=sc.nextInt();
		    int arr[]=new int[n];
	       for(int j=0;j<n;j++){
	           arr[j]=sc.nextInt();
	       }
	       Arrays.sort(arr);
	      long result=0;
	      int iterations=n-l;
	      while(iterations>=0){
	          result=result+arr[iterations];
	          iterations-=k;
	      }
	      System.out.println(result);

		}
	}
}

:exploding_head: DAMM!!!

Honestly for few seconds the First thought that came to my mind was “CodeChef is really Racist”. But after sometime when I carefully observe the ONE & ONLY diff in my and his solution was he had declared the “SUM AS LONG” & I had declare the “SUM AS INT”

But according to the Constraints The sum of N across all tests won't exceed 2.10^5 So here I declare the sum as data type int Which can hold values up to 10^9 which obviously greater than 2.10^5

Therefore according to the constraints declaring Sum as Int or Long must not matter then why is Solution with Sum as Int is Not Accepted & Solution With Sum as Long is Accepted .Also if this Solution with sum as int is not accepted due to sum’s size problem why it pass verdict WA(Wrong Answer) it should pass RTE(Runtime Error) as Sum gets large value that its maximum capacity.

If you know the reason behind this or what is this a judging error or codechef’s compiler has less range of an int or sometime else
any logical explanation is welcomed

Do Like :blue_heart: the post so it is reached to more people
& also You May Reply :speech_balloon: if you know how to tackle this situation.

Query from: @Vishu_17

1 Like