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:
print("impossible")
else:
print(maxi)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2900 KB |
Output is correct |
2 |
Correct |
17 ms |
2920 KB |
Output is correct |
3 |
Correct |
19 ms |
2820 KB |
Output is correct |
4 |
Correct |
15 ms |
2920 KB |
Output is correct |
5 |
Correct |
15 ms |
2844 KB |
Output is correct |
6 |
Correct |
14 ms |
2900 KB |
Output is correct |
7 |
Correct |
14 ms |
2900 KB |
Output is correct |
8 |
Correct |
15 ms |
2900 KB |
Output is correct |
9 |
Correct |
15 ms |
2828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2081 ms |
2944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2072 ms |
6424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2039 ms |
27588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |