Here are two links with almost exact codes one of them passed both test cases but one of them did not, please tell me the difference between the two.
**Giving TLE in the second test case(I wrote this one)
**Passed all the test case
Here are two links with almost exact codes one of them passed both test cases but one of them did not, please tell me the difference between the two.
**Giving TLE in the second test case(I wrote this one)
**Passed all the test case
what’s the use of that
Please tell me the defect in the code , there is no use of curly braces the testcase is showing TLE not wrong answer
Your code is not Terminating for big input
its working fine :
import java.util.*;
class Main{
public static void solve(){
long q = scn.nextLong();
long k = scn.nextLong();
PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());
while(q–>0){
long cas = scn.nextLong();
if(cas == 1){
long x = scn.nextLong();
long y = scn.nextLong();
long rd = x*x + y*y;
if(pq.size()<k){
pq.add(rd);
}else{
if(rd<pq.peek()){
pq.poll();
pq.add(rd);
}
}
}else{
System.out.println(pq.peek());
}
}
}
public static Scanner scn = new Scanner(System.in);
public static void main(String[] args){
solve();
}
}
this is not my code this is the code which I copied from somewhere ,I want to ask what is the problem with the code in the first link. I know this one is write but WHAT IS THE PROBLEM WITH THIS.ONE ??
ok thanks bro