MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Hackerrank_problems/Array Manipulation/solution.cpp:16–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16int main() {
17 long int N,K,p,q,sum,i,j,max=0,x=0;
18
19 cin>>N>>K;
20 long int *a=new long int[N+1]();
21
22 for(i=0;i<K;i++)
23 {
24 cin>>p>>q>>sum;
25 a[p]+=sum;
26 if((q+1)<=N) a[q+1]-=sum;
27 }
28
29 for(i=1;i<=N;i++)
30 {
31 x=x+a[i];
32 if(max<x) max=x;
33
34 }
35
36 cout<<max;
37 return 0;
38}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected