|
|
вернуться в форумJAVA WA#11 TIME LIMIT , SOMEONE CAN HELP ME? Послано Julius 26 ноя 2015 08:18 here is my code if someone can help me, thanks you and greetings. import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; public class P1100 { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int [] vec=new int[n*2]; for(int i=0;i<n*2;i++)vec[i]=in.nextInt(); int [] aux=new int[n]; int mayor=0,menor=100; for(int i=1;i<n*2;i=i+2){ if(menor>vec[i]){ menor=vec[i]; } if(mayor<vec[i]){ mayor=vec[i]; } } int sig=-1; for(int i=0;i<n;i++){ for(int j=1;j<n*2;j=j+2){ if(mayor==vec[j] && vec[j]!=-1 ){ System.out.printf(" %d %d",vec[j-1],vec[j]); vec[j]=-1;
} if(sig<mayor && sig < vec[j] && vec[j]!=-1){ sig=vec[j]; } } mayor=sig; sig=-1; } out.flush();
} } |
|
|