This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import sys
n, k, r = map(int, sys.stdin.readline().split())
dna = list(map(int, sys.stdin.readline().split()))
antal = []
tal = []
copi = []
maxi = n+1
for _ in range(r):
b, q = map(int, sys.stdin.readline().split())
tal.append(b)
antal.append(q)
copi.append(q)
B = []
for _ in range(r):
B.append(0)
for j in range(n):
h = 0
for i in range(j, n):
h += 1
if dna[i] in tal:
if antal[tal.index(dna[i])] != 0:
antal[tal.index(dna[i])] -=1
if antal == B:
if h < maxi:
maxi = h
antal = copi.copy()
if maxi == n+1:
sys.stdout.writelines("impossible")
else:
sys.stdout.writelines(str(maxi))
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |