Problem:


Score : 200 points

Problem Statement

Rng is preparing a problem set for a qualification round of CODEFESTIVAL.

He has N candidates of problems. The difficulty of the i-th candidate is D_i.

There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.

Determine whether Rng can complete the problem set without creating new candidates of problems.

Constraints

1 \leq N \leq 200,000

1 \leq D_i \leq 10^9

1 \leq M \leq 200,000

1 \leq T_i \leq 10^9

All numbers in the input are integers.

Partial Score

100 points will be awarded for passing the test set satisfying N \leq 100 and M \leq 100.

Input

Input is given from Standard Input in the following format:

N
D_1 D_2 ... D_N
M
T_1 T_2 ... T_M

Output

Print YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.

Sample Input 1

5
3 1 4 1 5
3
5 4 3

Sample Output 1

YES

Sample Input 2

7
100 200 500 700 1200 1600 2000
6
100 200 500 700 1600 1600

Sample Output 2

NO

Not enough 1600s.

Sample Input 3

1
800
5
100 100 100 100 100

Sample Output 3

NO

Sample Input 4

15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
9
5 4 3 2 1 2 3 4 5

Sample Output 4

YES



Sample input:
5
3 1 4 1 5
3
5 4 3


Sample output:
YES

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split())) 
m = int(input())
t = list(map(int, input().split())) 

from collections import Counter

dc, tc = Counter(d), Counter(t)
ans = "YES"
for p in tc.keys():
    if tc[p] > dc[p]:
        ans = "NO"
 
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D_list = list(map(int, input().split()))
M = int(input())
T_list = list(map(int, input().split()))

dic_T = {}
for i in T_list:
    if i in dic_T:
        dic_T[i] += 1
    else:
        dic_T[i] = 1

dic_D = {}
for i in D_list:
    if i in dic_D:
        dic_D[i] += 1
    else:
        dic_D[i] = 1

for i in dic_T:
    if i in dic_D:
        if not dic_T[i] <= dic_D[i]:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:

n = int(input())
d = sorted(map(int, input().split()))
m = int(input())
t = sorted(map(int, input().split()))
if n < m:
    print("NO")
    exit()

p = 0
ans = True

for i in range(m):
    while p < n and d[p] < t[i]:
        p += 1
    if p >= n or d[p] > t[i]:
        ans = False
    p += 1
print(["NO", "YES"][ans])

Submission status: Accepted

Solution code:
# B - Problem Set
def is_create(dic_d, t):
	for ti in t:
		if not ti in dic_d.keys():
			return False
		elif dic[ti] == 0:
			return False
		else:
			dic[ti] -= 1	
	
	return True


n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	dic.setdefault(di, 0)
	dic[di] += 1
	'''if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1'''

if is_create(dic, t):
	print('YES')
else:
	print('NO')

Submission status: Accepted

Solution code:
# B - Problem Set
def is_create(dic_d, t):
	for ti in t:
		if not ti in dic_d.keys():
			return False
		elif dic[ti] == 0:
			return False
		else:
			dic[ti] -= 1	
	
	return True


n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1

if is_create(dic, t):
	print('YES')
else:
	print('NO')

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    N = int(input())
    D = Counter([int(_) for _ in input().split()])
    M = int(input())
    T = Counter([int(_) for _ in input().split()])
    
    for t in T.keys():
        if D[t] < T[t]:
            print('NO')
            break
    else:
      print('YES')
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(map(int, input().split()))
m = int(input())
t = sorted(map(int, input().split()))
if n < m:
    print("NO")
    exit()
p = 0
ans = True
for i in range(m):
    while p < n and d[p] < t[i]:
        p += 1
    if p >= n or d[p] > t[i]:
        ans = False
    p += 1
print(["NO", "YES"][ans])

Submission status: Accepted

Solution code:
import collections

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

d = collections.Counter(D)
t = collections.Counter(T)

ans = 'YES'
t_v = list(t.values())
t_k = list(t.keys())
for i in range(len(t)):
    if t_v[i] > d[t_k[i]]:
        ans = 'NO'

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
h = defaultdict(int)
g = defaultdict(int)
for k in d:
    h[k] += 1
for k in t:
    g[k] += 1
f = True
for k in g.keys():
    if h[k] < g[k]:
        f = False
        break
print(("YES" if f else "NO"))

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()
M = INT()
T = LIST()
a = Counter(D)
b = Counter(T)
# print(a)
for d in T:
    if a[d] == 0:
        print("NO")
        exit()
    else:
        # print(d)
        # print(a[d])
        a[d] -= 1
print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    N = int( input())
    D = list( map( int, input().split()))
    M = int( input())
    T = list( map( int, input().split()))
    probs = defaultdict( int)
    for d in D:
        probs[d] += 1
    for t in T:
        if probs[t] == 0:
            print("NO")
            return
        probs[t] -= 1
    print("YES")
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split(" ")))
M = int(input())
T = list(map(int, input().split(" ")))
D.sort()
T.sort()

t = 0

for d in D:
    if t < len(T) and T[t] == d:
        t += 1
        d += 1

    if t == len(T):
        break

print('YES' if t == len(T) else 'NO')

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
d = map(int, input().split())
m = int(input())
t = map(int, input().split())

dc, tc = Counter(d), Counter(t)
ans = "YES"
for p in tc.keys():
    if tc[p] > dc[p]:
        ans = "NO"

print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
d = Counter(list(map(int, input().split())))
m = int(input())
t_list = list(map(int, input().split()))
t = Counter(t_list)

# print("d =", d)
# print("t =", t)

yes = True

for i in t_list:
    # print()
    # print("d =", d)
    # print("t =", t)
    if d[i] == 0:
        yes = False
        break   
    d[i] -= 1

if yes:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    D = list(map(int, input().split()))
    m = int(input())
    T = list(map(int, input().split()))

    P = Counter(D)

    for i in range(m):
        P[T[i]] -= 1

    for v in P.values():
        if v < 0:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dd = Counter(d)
tt = Counter(t)
# print(dd, tt)
ok = True
for i, j in tt.items():
    if i in dd:
        # print('Y')
        if dd[i] < j:
            ok = False
    else:
        ok = False
    # print(i, j, ok)

if ok:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:

def myAnswer(N:int,D:list,M:int,T:list) -> str:
   dic = {key:0 for key in T}
   for d in D:
      if(d in dic.keys()):
         dic[d] += 1
   for t in T:
      if(dic[t] == 0):
         return "NO"
      else:
         dic[t] -= 1
   return "YES"

def modelAnswer():
   return
def main():
   N = int(input())
   D = list(map(int,input().split()))
   M = int(input())
   T = list(map(int,input().split()))
   print(myAnswer(N,D[:],M,T[:]))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = sorted(list(map(int,input().split())))
ans = 'YES'
x = 0
for i in t:
    while  x<n and d[x]<i:
        x+=1
    if x==n or i!=d[x]:ans='NO'
    else:x+=1
print(ans)

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrD = list(map(int,input().split()))
M = int(input())
arrT = list(map(int,input().split()))

cntD = Counter(arrD)
cntT = Counter(arrT)

for dif,cnt in cntT.items():
    if dif in cntD:
        if cnt > cntD[dif]:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

print("YES")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d = Counter(sorted(d))
cnt = 0
for i in range(m):
    if t[i] in d and d[t[i]] > 0:
        d[t[i]] -= 1
        cnt += 1
    else: break
print("YES" if cnt == m else "NO")

Submission status: Accepted

Solution code:
import sys
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

max_diff = max(D)
difficulty = {}
for d in D:
    try:
        difficulty[d] += 1
    except:
        difficulty[d] = 1

for t in T:
    try:
        difficulty[t] -= 1
    except:
        print('NO')
        sys.exit()
    if difficulty[t] < 0:
        print('NO')
        sys.exit()
print('YES')

Submission status: Accepted

Solution code:
import collections

n = int(input())
d = [int(_) for _ in input().split()]
m = int(input())
t = [int(_) for _ in input().split()]

D = collections.Counter(d)
nd = dict.fromkeys(D, 0)

for i in range(m):
    if t[i] in nd:
        get_cnt = nd[t[i]] + 1
        if get_cnt <= D[t[i]]:
            nd[t[i]] = get_cnt
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    N, D = int(input()), Counter(list(map(int, input().split())))
    M, T = int(input()), Counter(list(map(int, input().split())))
    result = "YES"
    for key, value in T.items():
        temp = D.get(key)
        if temp == None or temp < value:
            result = "NO"
            break
    print(result)
main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
dl = list(map(int, input().split()))
m = int(input())
tl = list(map(int, input().split()))

dc = Counter(dl)
tc = Counter(tl)

for k in tc:
    if dc[k]<tc[k]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
D.sort()
M = int(input())
T = list(map(int,input().split()))
T.sort()

dindex = 0
for i in range(M):
  while 1:
    dindex += 1
    if T[i] == D[dindex-1]:
      break
    elif dindex == N:
      print('NO')
      exit()
print('YES')

Submission status: Accepted

Solution code:
import bisect
n = int(input())
d_li = list(map(int,input().split()))
m = int(input())
t_li = list(map(int,input().split()))

import collections
d_cnt = collections.Counter(d_li)
t_cnt = collections.Counter(t_li)
#print(d_cnt,t_cnt)

for t in t_cnt.items():
    #print(d_cnt,d_cnt[t[0]],t[1])
    if d_cnt[t[0]] < t[1]:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
from collections import*
i = eval("Counter(list(map(int, input().split()))),"*4)
print("YNEOS"[i[3]-i[1] != {}::2])

Submission status: Accepted

Solution code:
from collections import*
i = eval("Counter(list(map(int, input().split()))),"*4)
print("YNEOS"[any(i[1][j] < k for j, k in i[3].items())::2])

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

c1 = Counter(D)
c2 = Counter(T)

for t in c2.keys():
    if c2[t] > c1[t]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()
M = INT()
T = LIST()

cnt_D = Counter(D)
cnt_T = Counter(T)
for t in T:
	if cnt_D[t] < cnt_T[t]:
		print("NO")
		break
else:
	print("YES")

Submission status: Accepted

Solution code:
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d=collections.Counter(d)
t=collections.Counter(t)
#print(d)
#print(t)
for i in t.keys():
    if d[i]<t[i]:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
from collections import Counter 

N=int(input())
C = Counter(list(map(int,input().split())))
O=int(input())
M = Counter(list(map(int,input().split())))
for key in M.keys():
  if C[key]<M[key]:
    print("NO")
    break
else:
  print("YES")

Submission status: Accepted

Solution code:
n=int(input())
d=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))
if m>n:
    print("NO")
else:
    a=0
    for i in range(m):
        flag=0
        while flag!=1:
            if a==n:
                print("NO")
                exit()
            if t[i]>d[a]:
                a+=1
            elif t[i]==d[a]:
                a+=1
                flag=1
            else:
                print("NO")
                exit()
    print("YES")

Submission status: Accepted

Solution code:
import collections
n = int(input())
d = list(map(int,input().split()))
dc = collections.Counter(d)

m = int(input())
t = list(map(int,input().split()))
dt = collections.Counter(t)

for k,v in dt.items():
    if dc[k] < v:
        print("NO")
        exit()

print("YES")

Submission status: Accepted

Solution code:
n = int(input())
D = sorted(list(map(int,input().split())))
m = int(input())
T = sorted(list(map(int,input().split())))

ans = 'YES'
di = -1
for t in T:
  while True:
    di += 1
    if di >= n:
      ans = 'NO'
      break    
    if D[di] == t:
      break
        
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    dc = Counter(d)
    tc = Counter(t)
    for k, v in tc.items():
        if dc[k]<v:
            print('NO')
            break
    else:
        print('YES')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d= Counter(list(map(int, input().split())))
m = int(input())
t= Counter(list(map(int, input().split())))
if t-d=={}:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import collections

N = int(input())
D = map(int, input().split())
M = int(input())
T = map(int, input().split())

DC = collections.Counter(D)

for t in T:
    if t in DC:
        if DC[t] > 0:
            DC[t] -= 1
            continue

    print('NO')
    break

else:
    print('YES')

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d.sort(reverse=True)
t.sort(reverse=True)

for i in range(n):
    if t[-1]==d[-1]:
        d.pop()
        t.pop()
    else:
        d.pop()
    if t==[]:
        print("YES")
        exit()
    if d==[]:
        print("NO")
        exit()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    D_c=Counter(D)
    M=int(input())
    T=[int(_) for _ in input().split()]
    T_c=Counter(T)
    for t in T_c.items():
        if D_c[t[0]]<t[1]:
            print("NO")
            break
    else:
        print("YES")

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import collections
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]

c = collections.Counter(d)


for i in t:
  if i in c:
    c[i] = c[i] - 1
  elif i not in c:
    print("NO")
    exit()


for i in c:
  if c[i] < 0:
    print("NO")
    exit()

print("YES")

Submission status: Accepted

Solution code:
from collections import Counter  # https://note.nkmk.me/python-scipy-connected-components/
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():
        N = int(input())
        D = list(map(int, input().split()))
        M = int(input())
        T = list(map(int, input().split()))

        DD = Counter(D)
        TT = Counter(T)

        for key, value in TT.items():
            if DD[key] < value:
                return 'NO'
        return 'YES'

    print(main())


resolve()

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

D.sort()
T.sort()
if N<M:
    print("NO")
    exit()

flag=True
cnt=0
count=0
for i in range(M):
    if cnt>=N:
        flag=False
        break
    chk=0
    while(D[cnt]!=T[i]):
        cnt+=1
        chk=1
        if cnt==N:
            flag=False
            break
    if cnt>=N:
        break
    if D[cnt]==T[i]:
        count+=1
    cnt+=1

if count==M:
    pass
else:
    flag=False

if flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

from collections import Counter
cntr = Counter(D)
ans = 'YES'
for t in T:
  if cntr.get(t) == None or cntr.get(t) == 0:
    ans = 'NO'
    break
  else:
    cntr[t] -= 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
d.sort()
t.sort()
i=0
j=0
stat=''
while i < n and j < m:
  if d[i]==t[j]:
    i+=1
    j+=1
  elif d[i]>t[j]:
    print('NO')
    exit()
  elif d[i]<t[j]:
    i+=1
print('YES' if j==m else 'NO')

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
d = [int(i) for i in input().split()] # 配列で数字

m = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
t = [int(i) for i in input().split()]

if n < m:
    print('NO')
else:
    d_c = Counter(d)
    t_c = Counter(t)
    for k, v in t_c.items():
        n = d_c.get(k, 0)
        if n >= v:
            continue
        else:
            print('NO')
            break
    else:
        print('YES')

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()
j = 0
#print(d)
#print(t)
for i in range(n):
    if d[i] == t[j]:
        if j < m-1:
            j += 1
        else:
            j += 1
            break

if j == m:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
d = [int(i) for i in input().split()] # 配列で数字

m = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
t = [int(i) for i in input().split()]

def bs(nums, target):
    l = 0
    r = len(nums) - 1
    while l <= r:
        mid = (l + r) // 2
        if nums[mid] == target:
            return mid
        elif nums[mid] > target:
            r = mid - 1
        else:
            l = mid + 1
    return -1

if n < m:
    print('NO')
else:
    d.sort()
    t.sort()
    i = j = 0
    while i < n and j < m:
        if d[i] == t[j]:
            i += 1
            j += 1
        else:
            i += 1
    if j == m:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cnt = {}
for d in D:
    if d not in cnt:
        cnt[d] = 1
    else:
        cnt[d] += 1
ans = True
for t in T:
    if t not in cnt:
        ans = False
        break
    elif cnt[t] == 0:
        ans = False
        break
    else:
        cnt[t] -= 1

if ans:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import bisect

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()

set_t = list(set(t))


for i in range(len(set_t)):
    n_d = bisect.bisect_right(d,set_t[i]) - bisect.bisect_left(d,set_t[i])
    n_t = bisect.bisect_right(t,set_t[i]) - bisect.bisect_left(t,set_t[i])
    
    if n_t > n_d:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

import collections
dict_D = dict(collections.Counter(D))
dict_T = dict(collections.Counter(T))

for k, v in dict_T.items():
    if v <= dict_D.get(k, 0):
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
n = int(input())
d = [int(x) for x in input().split()]
m = int(input())
t = [int(x) for x in input().split()]

from collections import Counter

t = dict(Counter(t))
d = dict(Counter(d))
for i in t.keys():
    if d.get(i)==None or d.get(i)<t.get(i):
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:
        ok = False
        break
    if dcnt[t[i]] == 0:
        ok = False
        break
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = [int(x) for x in input().split()]
m = int(input())
t = [int(x) for x in input().split()]

D = Counter(d)
T = Counter(t)

ans = "YES"
for x in T.keys():
    if D[x] < T[x]:
        ans = "NO"
        break

print(ans)

Submission status: Accepted

Solution code:
import collections

n=int(input())
d=list(map(int,input().split()))
d=collections.Counter(d)
m=int(input())
t=list(map(int,input().split()))
t=collections.Counter(t)


for i in t:
    if t[i]>d[i]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
for x in T[::-1]:
    while 1:
        if len(D)==0:
            print('NO')
            exit()
        temp = D.pop()
        if temp==x:
            break
print('YES')

Submission status: Accepted

Solution code:
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
for x in T[::-1]:
    while 1:
        if len(D)==0:
            print('NO')
            exit()
        temp = D.pop()
        if temp==x:
            break
else:
    print('YES')

Submission status: Accepted

Solution code:
import collections
N = int(input())
D = collections.Counter(list(map(int,input().split())))
M = int(input())
T = collections.Counter(list(map(int,input().split())))
for x in T:
    if D[x]<T[x]:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
N = int(input())
D = sorted(list(map(int, input().split())))
M = int(input())
T = sorted(list(map(int, input().split())))
C = {}
for d in D:
    if d in C:
        C[d] += 1
    else:
        C[d] = 1
E = {}
for t in T:
    if t in E:
        E[t] += 1
    else:
        E[t] = 1
for key, val in E.items():
    if key in C:
        C[key] //= val

print('YES' if min([C[t] if t in C else 0 for t in T]) > 0 else 'NO')

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
d = list(map(int, input().split()))

m = int(input())
t = list(map(int, input().split()))

d_cnt = Counter(d)
t_cnt = Counter(t)

flag = True
for k, v in t_cnt.items():
    if k in d_cnt.keys():
        if v > d_cnt[k]:
            flag = False
            break
    
    else:
        flag = False
        break
print("YES" if flag else "NO")

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

c1 = Counter(D)
c2 = Counter(T)

ans = 'YES'
for k, v in c2.items():
    if not k in c1.keys():
        ans = 'NO'
        break
    if c1[k] < v:
        ans = 'NO'
        break

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
d_ans = dict(Counter(d))
t_ans = dict(Counter(t))
flag = True
for i in t_ans:
    if i not in d_ans:
        flag = False
        
    else:
        if t_ans[i] > d_ans[i]:
            flag = False
print('YES' if flag==True else 'NO')