We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Data Structures
  3. Arrays
  4. Array Manipulation
  5. Discussions

Array Manipulation

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • gg_germain 3 years ago+ 0 comments

    Just improved your code a bit. - split() is slightly faster than split("") - an if was not needed as always true - variables names fit those used in the exercise

    if __name__ == "__main__":
        n, m = [int(n) for n in input().split()]
        l = [0]*(n+1)
        for _ in range(m):
            a, b, k = [int(n) for n in input().split()]
            l[a-1] += k
            l[b] -= k;
        max = a = 0
        for i in l:
           a+=i;
           if max<a:
                max=a;
        print(max)
    
    1|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature