fork download
  1. from sys import stdin
  2.  
  3. def getInt():
  4. return int(stdin.readline())
  5.  
  6. def getInts():
  7. return tuple(int(_) for _ in stdin.readline().split())
  8.  
  9. numCases = getInt()
  10. for caseIndex in xrange(1, 1 + numCases):
  11. (numStudents, numChocolates) = getInts()
  12. chocolateAmounts = [0] * numStudents
  13. for chocolateIndex in xrange(numChocolates):
  14. (fromStudent, toStudent, chocolateGift) = getInts()
  15. for studentIndex in xrange(fromStudent, toStudent+1):
  16. chocolateAmounts[studentIndex] += chocolateGift
  17. numFriends = getInt()
  18. for friendIndex in xrange(numFriends):
  19. friendPosition = getInt()
  20. print chocolateAmounts[friendPosition]
Success #stdin #stdout 0.01s 7740KB
stdin
1
6 4
3 5 2
2 4 3
1 5 1
0 2 4
4
4
3
2
0
stdout
6
6
8
4