Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = open('26.txt').readlines()
- n, k, Q = map(int, data[0].split())
- a = []
- for e in data[1:]:
- a.append(tuple(map(int, e.split())))
- a.sort()
- inf = 1000000000
- mx_s = a[-1][0]
- dp = [[inf for j in range(Q + 1)] for i in range(mx_s + 1)]
- cur_a = 0
- mn = inf
- for s in range(1, mx_s + 1):
- if s < a[cur_a][0]:
- continue
- if cur_a != n and s == a[cur_a + 1][0]:
- cur_a += 1
- dp[s][1] = min(mn, a[cur_a][1])
- mn = dp[s][1]
- for q in range(2, Q + 1):
- cur_a = 0
- mn = inf
- for s in range(1, mx_s + 1):
- if a[cur_a][0] - k < a[0][0] or dp[a[cur_a][0] - k] :
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement