Last time 0 was completed, but this time it is 5 completed.

It is necessary to replace 1-indexed with 0-indexed, but just judge according to the problem statement.

```
A = list(map(int, input().split()))
if A[0] < A[1] and A[2] > A[3]:
print('YES')
else:
print('NO')
```

Just output the H-shifted value.

```
N, H, *T = map(int, open(0).read().split())
print(*[t + H for t in T])
```

For all 12 keys, try all to see if only the notes contained in each key are used.

```
N, *T = map(int, open(0).read().split())
x = [0, 2, 4, 5, 7, 9, 11]
result = -1
for i in range(12):
t = set((i + e) % 12 for e in x)
for e in T:
if e not in t:
break
else:
if result == -1:
result = i
else:
print(-1)
exit()
print(result)
```

I solved it while thinking that it could be solved even with the scale method.

```
from bisect import bisect_left
N, D, *A = map(int, open(0).read().split())
t = sorted(A)
for a in A:
print(bisect_left(t, a - D))
```

I solved it with DP, thinking that it was heavy to implement. At first, I calculated even if the total complexity exceeded K and ate TLE, otherwise it would be TLE if it was not PyPy.

```
N, M, K = map(int, input().split())
m = 1000000007
pqc = [[] * 301 for _ in range(301)]
for _ in range(M):
P, Q, C = map(int, input().split())
pqc[P].append((Q, C))
t = [{0: 1} for _ in range(301)]
for i in range(N - 1):
nt = [{} for _ in range(301)]
for j in range(1, 301):
for k in t[j]:
for q, c in pqc[j]:
v = k + c
if v <= K:
nt[q].setdefault(v, 0)
nt[q][v] += t[j][k]
nt[q][v] %= m
t = nt
result = 0
for i in range(1, 301):
t[i].setdefault(K, 0)
result += t[i][K]
result %= m
print(result)
```

Recommended Posts