Hackerrank solutions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
509 B

#!/usr/bin/python3
# https://www.hackerrank.com/challenges/filling-jars
import sys
def nextints():
return [ int(x) for x in sys.stdin.readline().split() ]
def new_candies(start, end, new_per_jar):
return (end - start + 1) * new_per_jar
def main():
total = 0
[num_jars, num_ops] = nextints()
for _ in range(num_ops):
[start, end, new_per_jar] = nextints()
total += new_candies(start, end, new_per_jar)
print(total // num_jars)
if __name__ == '__main__':
main()