Created
March 11, 2015 03:16
-
-
Save cc2011/01d5e83fb992d7c0bc8b to your computer and use it in GitHub Desktop.
codechef COOLING http://www.codechef.com/problems/COOLING
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
//codechef COOLING http://www.codechef.com/problems/COOLING | |
import java.io.PrintWriter; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
import java.util.*; | |
public class Main{ | |
Scanner in; | |
String INPUT = ""; | |
void solve() { | |
int tc = ni(); | |
List<Integer> output = new ArrayList<Integer>(); | |
for(int i = 0; i < tc; i++) { | |
int arrSize = ni(); | |
int[] pieArr = new int[arrSize]; | |
int[] rackArr = new int[arrSize]; | |
for(int j=0; j < pieArr.length;j++) { | |
pieArr[j] = ni(); | |
} | |
for(int j=0; j < rackArr.length;j++) { | |
rackArr[j] = ni(); | |
} | |
Arrays.sort(pieArr); | |
Arrays.sort(rackArr); | |
int currKIndex = 0; | |
int count = 0; | |
for(int j = 0; j < pieArr.length; j++) { | |
int k; | |
for( k = currKIndex ; k < rackArr.length; k++) { | |
if(pieArr[j] <= rackArr[k]) { | |
count++; | |
currKIndex = k+1; | |
break; | |
} | |
} | |
} | |
System.out.println(count); | |
} | |
} | |
void run() throws Exception | |
{ | |
in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT); | |
solve(); | |
} | |
public static void main(String[] args) throws Exception | |
{ | |
new Main().run(); | |
} | |
int ni() { return Integer.parseInt(in.next()); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment