- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstalling.java
More file actions
Latest commit
31 lines (31 loc) · 992 Bytes
/
Copy pathstalling.java
File metadata and controls
31 lines (31 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
importjava.io.*;
importjava.util.*;
classstalling {
publicstaticvoidmain (String[] args) throwsIOException{
Scannerstdin = newScanner(System.in);
intnumCows = Integer.parseInt(stdin.nextLine());
StringTokenizerst = newStringTokenizer(stdin.nextLine());
int[] heights = newint[numCows];
for (inti = 0; i < numCows; i++) {
heights[i] = Integer.parseInt(st.nextToken());
}
Arrays.sort(heights);
StringTokenizerst2 = newStringTokenizer(stdin.nextLine());
int[] stallHeight = newint[numCows];
for (inti = 0; i < numCows; i++) {
stallHeight[i] = Integer.parseInt(st2.nextToken());
}
longtotal = 1;
intnumPass = 0;
for (inti = numCows-1; i > -1; i--) {
//System.out.println(numPass + " " + total);
numPass = 0;
for (intj = 0; j < numCows; j++) {
if (heights[i] <= stallHeight[j]) {
numPass++;
}
} total *= numPass - (numCows - i-1);
}
System.out.println(total);
}
}