Created
October 5, 2014 18:27
GetRange
This file contains hidden or 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
import java.io.File; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String [] args) throws IOException { | |
Scanner sc = new Scanner(new File("data.txt")); | |
//Scanner sc = new Scanner(System.in); | |
PrintWriter out = new PrintWriter(System.out); | |
while (sc.hasNextInt()) { | |
int ammount = sc.nextInt(); | |
int [] nums = new int[ammount]; | |
int index = 0; | |
while (ammount > 0) { | |
--ammount; | |
nums[index++] = sc.nextInt(); | |
} | |
int lowBound = sc.nextInt(); | |
int topbound = sc.nextInt(); | |
Arrays.sort(nums); | |
int topIndex = nums.length - 1; | |
int bottomIndex = 0; | |
while (lowBound >= nums[bottomIndex]) ++bottomIndex; | |
while (topbound <= nums[topIndex]) --topIndex; | |
int res = topIndex - bottomIndex + 1; | |
out.println(res); | |
out.flush(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment