codeforces/580B_company.py
def calculate(self):
        """ Main calcualtion function of the class """

        result = 0

        # Sorting both arrays by using first array as a key
        self.numa, self.numb = zip(*sorted(zip(self.numa, self.numb)))

        # Calculating partial sums
        self.psum = [0]
        for i in range(self.n):
            self.psum.append(self.psum[-1] + self.numb[i])

        # Calculating result
        for i in range(self.n):
            mrb = self.numa[i] + self.d
            sum = self.psum[lbound(self.numa, mrb)] - self.psum[i]
            result = max(result, sum)

        return str(result)
 Main calcualtion function of the class 
Main calcualtion function of the class
Main calcualtion function of the class
def calculate(self):
        result = 0
        self.numa, self.numb = zip(*sorted(zip(self.numa, self.numb)))
        self.psum = [0]
        for i in range(self.n):
            self.psum.append(self.psum[-1] + self.numb[i])
        for i in range(self.n):
            mrb = self.numa[i] + self.d
            sum = self.psum[lbound(self.numa, mrb)] - self.psum[i]
            result = max(result, sum)
        return str(result)
def calculate ( self ) : result = 0 self . numa , self . numb = zip ( * sorted ( zip ( self . numa , self . numb ) ) ) self . psum = [ 0 ] for i in range ( self . n ) : self . psum . append ( self . psum [ - 1 ] + self . numb [ i ] ) for i in range ( self . n ) : mrb = self . numa [ i ] + self . d sum = self . psum [ lbound ( self . numa , mrb ) ] - self . psum [ i ] result = max ( result , sum ) return str ( result )
Main calcualtion function of the class
Main calcualtion function of the class
""" Main calcualtion function of the class """ # Sorting both arrays by using first array as a key # Calculating partial sums # Calculating result
self