Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file = open('3A.txt')
- N, V, M = map(int, file.readline().split())
- a = []
- for x in file:
- km, k = map(int, x.split())
- a.append((km, k))
- max_con = 0
- max_tub = 0
- for i in range(N):
- cur_con, cur_tub = 0, 0
- for j in range(N):
- r = abs(a[j][0] - a[i][0])
- if r <= M:
- cur_tub += a[j][1]
- cur_con += (a[j][1] + V - 1) // V
- if cur_tub > max_tub:
- max_tub = cur_tub
- max_con = cur_con
- print(max_con)
- file = open('3B.txt')
- N, V, M = map(int, file.readline().split())
- a = []
- for x in file:
- km, k = map(int, x.split())
- a.append((km, k))
- max_con = 0
- max_tub = 0
- a.sort()
- l = r = 0
- cur_tub = cur_con = max_tub = max_con = 0
- for st in range(N):
- while r < N and a[r][0] - a[st][0] <= M:
- cur_tub += a[r][1]
- cur_con += (a[r][1] + V - 1) // V
- r += 1
- while a[st][0] - a[l][0] > M:
- cur_tub -= a[l][1]
- cur_con -= (a[l][1] + V -1) // V
- l += 1
- if cur_tub > max_tub:
- max_tub = cur_tub
- max_con = cur_con
- print(max_con)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement