Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions 0224LJH/202512/09 BOJ 누가 이길까.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
```java

import java.util.StringTokenizer;
import java.util.*;
import java.io.*;

public class Main {

static int[] total = new int[2];
static long[][] people = new long[2][100001];
static long[][] cumul = new long[2][100001];
static long win,lose,draw;

public static void main(String[] args) throws IOException {
init();
process();
print();

}

private static void init() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
total[0] = Integer.parseInt(st.nextToken());
total[1] = Integer.parseInt(st.nextToken());
win = 0;
lose = 0;
draw = 0;

for (int i = 0 ; i < 2; i++) {
st = new StringTokenizer(br.readLine());

for (int j = 0; j < total[i]; j++) {
int num = Integer.parseInt(st.nextToken());
people[i][num]++;
}
}



}

private static void process() throws IOException {
for (int i = 1; i<= 100000; i++) {
for (int j = 0; j < 2; j++) {
cumul[j][i] = cumul[j][i-1] + people[j][i];
}
}

for (int i = 1; i <= 100000; i++) {
win += people[0][i] * (cumul[1][i-1]);
lose += people[1][i] * (cumul[0][i-1]);
draw += people[0][i] * people[1][i];
}


}

private static void print() {
System.out.println(win + " "+ lose +" " + draw);
}

}
```