#include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          long n,q,a,b,k,temp=0,max=-1000000007;
          cin>>n>>q;
          vector <int> arr(n+1,0);
          for(int i=0;i<q;i++)
          {
              cin>>a>>b>>k;
              arr.at(a-1) += k;
              arr.at(b)   -= k;
          }
          for(int i=0;i<n;i++)
          {
              temp += arr.at(i);
              if(temp>max)
                  max = temp;
          }
          cout<<max;
          return 0;
      }
      
      Cpp language logo

      Array Manipulation

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.