S10E - Editorial

@ssjgz thank you for explanation, my logic was correct but i had done a mistake when sorting vector in “ist” function. This is my solution, plz review it.

1 Like

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
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
StringBuilder sb=new StringBuilder();
while(t–>0)
{
int n=Integer.parseInt(br.readLine());
String in[]=new String[n];
in=br.readLine().split(" “);
int c=0;
int arr[]=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=Integer.parseInt(in[i]);
int m=Integer.MAX_VALUE;
for(int j=i-1;j>=Math.max(0,i-5);j–)
{
if(arr[j]<m)
m=arr[j];
}
if(arr[i]<m)
c++;
}
sb.append(c+”\n");
}
System.out.print(sb);
}
}

This code is getting accepted but for the following test input, the ans should be 2 ,but this code is giving 3 as ans. How come this code is getting accepted?

input-

1
7
375 300 900 723 662 647 200

o/p = 3 which is wrong, but still this code is getting accepted. Why?