Untitled

mail@pastecode.io avatar
unknown
python
3 years ago
689 B
9
Indexable
Never
n = int(input())
t = int(input())
list = []
for x in range(n):
  temp = int(input())
  list.append({'start': temp, 'end': 0})

for x in range(n):
  temp = int(input())
  item = list[x];
  item['end'] = item['start'] + temp*t

list.sort(key=lambda x: x['start'])

# sort the array by start position and save the startindex
for x in range(n):
  item = list[x];
  item['startindex'] = x

# sort the array by end position
list.sort(key=lambda x: x['end'])

overtakes=0

# find the elements who who's start position is smaller and end position is larger
for x in range(n):
  item = list[x]
  startindex = item['startindex']
  if startindex < x:
    overtakes += x - startindex

print(overtakes)