No Idea!

Sort by

recency

|

1501 Discussions

|

  • + 0 comments

    A oneliner:

    n, m = map(int, input().split())
    arr = list(map(int, input().split()))
    arr_a = set(map(int, input().split()))
    arr_b = set(map(int, input().split()))
    
    print(sum(1 if e in arr_a else -1 if e in arr_b else 0 for e in arr))
    
  • + 0 comments
    n,m=list(map(int,input().split()))
    arr=list(map(int,input().split()))
    A,B=set(map(int,input().split())),set(map(int,input().split()))
    a,b=[x for x in arr if x in A],[x for x in arr if x in B]
    print(len(a)-len(b))
    
  • + 1 comment

    x = list(map(int, input().split())) my_set = list(map(int, input().split())) set_A = list(map(int, input().split())) set_B = list(map(int, input().split())) score = 0

    for i in my_set: if i in set_A: score += 1 if i in set_B: score -= 1

    print(score)

    the time limit is exceeding, any help with that

    the

  • + 0 comments

    using a dictionary

    happiness = 0
    
    n, m = input().split()  # not used
    arry = input().split()
    A = set(input().split())
    B = set(input().split())
    
    d = {}
    for num in arry:
        if num not in d:
            d[num] = 1
        else:
            d[num] += 1
    
    for num, occurrences in d.items():
        if num in A:
            happiness += occurrences
        elif num in B:
            happiness -= occurrences
    
    print(happiness)
    
  • + 0 comments
    l=list(map(int,input().split()))
    happiness=0
    array=list(map(int,input().split()))
    A=set(list(map(int,input().split())))
    B=set(list(map(int,input().split())))
    for i in array:
        if i in A:
            happiness+=1
        if i in B:
            happiness-=1
    print(happiness)