Sort by

recency

|

201 Discussions

|

  • + 0 comments

    t = 0 for i in operations: t+=(i[1]-i[0]+1)*i[2] return int(t/n)

  • + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    def solve(n, operations): count = 0 for i in range(m): l = operations[i] a = l[0] b = l[1] k = l[2] count += (b-a+1)*k return count//n

    if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')

    first_multiple_input = input().rstrip().split()
    
    n = int(first_multiple_input[0])
    
    m = int(first_multiple_input[1])
    
    operations = []
    
    for _ in range(m):
        operations.append(list(map(int, input().rstrip().split())))
    
    result = solve(n, operations)
    
    fptr.write(str(result) + '\n')
    
    fptr.close()
    
  • + 1 comment

    what is wrong with c++ solution why all the test cases are not passing

  • + 0 comments
    def solve(n, operations):
        count=0
        for operation in operations:
                count+=operation[2] *(operation[1]-operation[0]+1)
        return math.floor(count/n)
    
  • + 1 comment

    For C++ solution change the return type of solve function to long long and also type of result variable in main function from where solve is being called.