Skip to content

Instantly share code, notes, and snippets.

@PreSoichiSumi
Created April 26, 2016 07:56
Show Gist options
  • Save PreSoichiSumi/5095934c43fb9d4904e46a4471b3ef70 to your computer and use it in GitHub Desktop.
Save PreSoichiSumi/5095934c43fb9d4904e46a4471b3ef70 to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int L=sc.nextInt();
int H=sc.nextInt();
int N=sc.nextInt();
List<Integer> list=new ArrayList<Integer>();
for(int i=0;i<N;i++){
list.add(sc.nextInt());
}
for(Integer i:list){
if(L<=i && i<= H){
System.out.println(0);
}else if(i<L){
System.out.println(Math.abs(L-i));
}else{
System.out.println(-1);
}
}
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment