Skip to content

Instantly share code, notes, and snippets.

@johirbuet
Created February 27, 2018 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johirbuet/cd920594b68b0bb3628a27dc07576750 to your computer and use it in GitHub Desktop.
Save johirbuet/cd920594b68b0bb3628a27dc07576750 to your computer and use it in GitHub Desktop.
import java.util.Arrays;
import java.util.Scanner;
public class UVA10474 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = 1;
while(sc.hasNextInt()) {
int N = sc.nextInt();
int Q = sc.nextInt();
if( N == 0 && Q == 0) {
break;
}
int [] arr = new int [N];
for(int i =0; i<N;i++) {
arr[i] =sc.nextInt();
}
Arrays.sort(arr);
System.out.printf("CASE# %d:\n",t++);
for(int q = 0;q<Q;q++) {
int x = sc.nextInt();
int index = -1;
for(int i =0;i<N;i++) {
if(arr[i] == x) {
index = i;
break;
}
}
if(index == -1) {
System.out.println(x+" not found");
}
else {
System.out.println(x+" found at "+(index + 1));
}
}
}
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment