Facebook
From Unique Prairie Dog, 5 Years ago, written in Python.
This paste is a reply to Re: Untitled from Emerald Pelican - go back
Embed
Viewing differences between Re: Untitled and Re: Re: Untitled
#!/bin/python3

import heapq
math
import os
import random
import re
import sys

# Complete the longestIncreasingSubsequence function below.
def getAvgWaitTime(n, cust):
    heap = []
    curTime = 0
    waitTime = 0
    cust = sorted(cust)
    i = 0

    while i < n:
        
findLIS(s):

if curTime < cust[i][0]:
            curTime 
__name__ == '__main__':
    fptr 
cust[i][0]
        while i < n and (curTime >= cust[i][0]):
            heapq.heappush(heap, (cust[i][1], cust[i][0]))
            i += 1

        while (i < n) and curTime < cust[i][0] and len(heap) > 0:
            time, wait = calculateWaiting(heap, curTime)
            curTime += time
            waitTime += wait

    # Clear all the jobs
    while len(heap) > 0:
        time, wait = calculateWaiting(heap, curTime)
        curTime += time
        waitTime += wait

    return waitTime / n


def calculateWaiting(heap, curTime):
    wait = 0
    cur = heapq.heappop(heap)
    wait = curTime - cur[1] + cur[0] 
    return (cur[0], wait)


open(os.environ['OUTPUT_PATH'], 'w')

    
n = int(input().strip())
cust 
int(input())

    arr 
[]
[]

    
for in range(n):
    ar 
range(n):
        arr_item 
list(map(int, input().strip().split(' ')))
    cust.append((ar[0], ar[1]))


int(input())
        arr.append(arr_item)

    
result = getAvgWaitTime(n, cust)
print(result)
findLIS(s)

    fptr.write(str(result) + '\n')

    fptr.close()

Replies to Re: Re: Untitled rss

Title Name Language When
Re: Re: Re: Untitled Trivial Anoa python 5 Years ago.