scar_ryokan

mail@pastecode.io avatar
unknown
plain_text
3 years ago
610 B
1
Indexable
Never
#include<iostream>
#include<cmath>
using namespace std;

void ProcessInArray(int a[], int u, int v, int k)
{
    for(int i = u-1; i<=v-1;i++)
        a[i] = a[i] + k;
}

int Max(int a[], int n)
{
    int M=0;
    for(int i=0; i<n; i++)
        if(M < a[i])
            M = a[i];
    return M;
}

int main()
{
    int n,m;
    cin>>n>>m;
    int*a = new int[n];
    for(int i=0; i<n; i++)
        a[i]=0;
    int u,v,k;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>k;
        ProcessInArray(a,u,v,k);
    }
    cout<<Max(a,n)<<endl;
    system("pause");
    return 0;
}