Home (Python)[백준] 임진왜란_3077
Post
Cancel

(Python)[백준] 임진왜란_3077

3077번: 임진왜란

풀이


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sys

input = sys.stdin.readline

n = int(input())

correct_answer = dict(zip(input().split(), [i for i in range(n)]))

to_check_answer = input().split()
cnt = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        if correct_answer[to_check_answer[i]] < correct_answer[to_check_answer[j]]:
            cnt += 1

print(cnt, "/", n * (n - 1) // 2, sep="")
This post is licensed under CC BY 4.0 by the author.