blob: 23f51e5b07ab154b56f3829f082c78988765d2eb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
|
#!/usr/bin/env python
for t in range(int(input())):
n = int(input())
w, l = list(map(int, input().split())), list(map(int, input().split()))
last, result, frogs = -1, 0, sorted(zip(w, range(n), l))
for weight, position, length in frogs:
hits = 0 if position > last else (last-position)//length + 1
last = position + hits*length
result += hits
print(result)
|