You are viewing a single comment's thread. Return to all comments →
nm = input() # Example input: "3 2"
n,m = map(int, nm.split())
array = list(map(int, input().split()))
A = set(map(int, input().split())) B = set(map(int, input().split()))
happiness = 0
for i in array: if i in A: happiness+=1 elif i in B: happiness -=1 else: happiness +=0 print(happiness)
Seems like cookies are disabled on this browser, please enable them to open this website
No Idea!
You are viewing a single comment's thread. Return to all comments →
Enter your code here. Read input from STDIN. Print output to STDOUT
Read a single line of input for n and m
nm = input() # Example input: "3 2"
Split the input line into parts and convert each to an integer
n,m = map(int, nm.split())
array = list(map(int, input().split()))
2sets: A: set, B:set each containing m integers
A = set(map(int, input().split())) B = set(map(int, input().split()))
happiness = 0
for i in array: if i in A: happiness+=1 elif i in B: happiness -=1 else: happiness +=0 print(happiness)