• + 2 comments

    Whats the problem with my code? only 7 test cases are showing wrong. Please help me with it.

    #include <cmath>
    #include <cstdio>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int main()
    {
        long int n,m;
        cin>>n>>m;
        long int arr[n];
        long int k;
        int a,b;
        for (long int i=0;i<n;i++)
        arr[i]=0;
        for (long int i=0;i<m;i++)
        {
            cin>>a>>b>>k;
            for (int j=a-1;j<=b-1;j++ )
            {
                arr[j]+=k;
            }
        }
        long int max=arr[0];
        for (long int k=0;k<n;k++)
        {
            if (arr[k]>max)
            max=arr[k];
        }
        cout<<max;
    
        return 0;
    }