|
| 1 | +```java |
| 2 | + |
| 3 | +import java.util.StringTokenizer; |
| 4 | +import java.util.*; |
| 5 | +import java.io.*; |
| 6 | + |
| 7 | +public class Main { |
| 8 | + |
| 9 | + static int[] total = new int[2]; |
| 10 | + static long[][] people = new long[2][100001]; |
| 11 | + static long[][] cumul = new long[2][100001]; |
| 12 | + static long win,lose,draw; |
| 13 | + |
| 14 | + public static void main(String[] args) throws IOException { |
| 15 | + init(); |
| 16 | + process(); |
| 17 | + print(); |
| 18 | + |
| 19 | + } |
| 20 | + |
| 21 | + private static void init() throws IOException{ |
| 22 | + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 23 | + StringTokenizer st = new StringTokenizer(br.readLine()); |
| 24 | + total[0] = Integer.parseInt(st.nextToken()); |
| 25 | + total[1] = Integer.parseInt(st.nextToken()); |
| 26 | + win = 0; |
| 27 | + lose = 0; |
| 28 | + draw = 0; |
| 29 | + |
| 30 | + for (int i = 0 ; i < 2; i++) { |
| 31 | + st = new StringTokenizer(br.readLine()); |
| 32 | + |
| 33 | + for (int j = 0; j < total[i]; j++) { |
| 34 | + int num = Integer.parseInt(st.nextToken()); |
| 35 | + people[i][num]++; |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + } |
| 42 | + |
| 43 | + private static void process() throws IOException { |
| 44 | + for (int i = 1; i<= 100000; i++) { |
| 45 | + for (int j = 0; j < 2; j++) { |
| 46 | + cumul[j][i] = cumul[j][i-1] + people[j][i]; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + for (int i = 1; i <= 100000; i++) { |
| 51 | + win += people[0][i] * (cumul[1][i-1]); |
| 52 | + lose += people[1][i] * (cumul[0][i-1]); |
| 53 | + draw += people[0][i] * people[1][i]; |
| 54 | + } |
| 55 | + |
| 56 | + |
| 57 | + } |
| 58 | + |
| 59 | + private static void print() { |
| 60 | + System.out.println(win + " "+ lose +" " + draw); |
| 61 | + } |
| 62 | + |
| 63 | +} |
| 64 | +``` |
0 commit comments