# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---





class Solution:
    def averageWaitingTime(self, customers):
        n = len(customers)
        cnt = 0
        s_time = 0
        for s, t in customers:
            if s_time is None:
                s_time = s + t
                cnt += t
            else:
                if s_time > s:
                    cnt += (s_time - s) + t
                    cnt += t
                else:
                    cnt += t
                s_time += t
            print(cnt)
        return cnt / n


class Solution:
    def averageWaitingTime(self, customers):
        n = len(customers)
        cnt = 0
        s_time = 0
        for s, t in customers:
            if s_time > s:
                s_time += t
            else:
                s_time = s + t
            cnt += (s_time - s)
        return cnt / n


solution = Solution()
solution.averageWaitingTime(customers = [[5,2],[5,4],[10,3],[20,1]])



StarcoderdataJupyterScriptsDedupFiltered