arrow_forward همه ارسال‌ها

جزئیات ارسال کد#412

verified
وضعیت داوری نهایی: محدودیت زمان تست 12
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
AmirHosein (۲ سال پیش)
descriptionsolution.py ۱۷ خط • ۴۱۸ بایت
1n = int(input())
2inp = list(map(int, input().split()))
3wire_cost = [0] * n
4seen = [False] * n
5again = [False] * n
6
7for i in range(2*n):
8 num = inp[i]-1
9 for j in range(n):
10 if seen[j] == True and again[j] == False:
11 wire_cost[j] += 1
12 if seen[num] == False:
13 seen[num] = True
14 elif seen[num] == True and again[num] == False:
15 again[num] = True
16
17print(sum(wire_cost))
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8