Last active
August 29, 2015 14:01
-
-
Save frojasg/a82f0fba40b793eabed5 to your computer and use it in GitHub Desktop.
problema 1234
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mport java.io.*; | |
import java.util.*; | |
class Main { | |
public static void main(String[] args) throws IOException { | |
BufferedReader br = | |
new BufferedReader(new InputStreamReader(System.in)); | |
String line = br.readLine(); | |
int cases = Integer.parseInt(line); | |
for(int i=0; i< cases; i++) { | |
br.readLine(); | |
String[] index = br.readLine().split(" "); | |
String[] values = br.readLine().split(" "); | |
Pair[] list = new Pair[index.length]; | |
for(int j=0; j < index.length ; j++) { | |
list[j] = new Pair(index[j], values[j]); | |
} | |
Arrays.sort(list); | |
for (Pair p : list) { | |
System.out.println(p.value); | |
} | |
if (i+1 < cases) { | |
System.out.println(); | |
} | |
} | |
} | |
} | |
class Pair implements Comparable<Pair> { | |
public String x; | |
public String value; | |
public Pair(String x, String v) { | |
this.x = x; | |
this.value = v; | |
} | |
public int compareTo(Pair p2) { | |
int x1 = Integer.parseInt(this.x); | |
int x2 = Integer.parseInt(p2.x); | |
return x1 - x2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
L18 esta mala