Advertisement
marco15432

Untitled

May 27th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int n,m,a,b,k;
  7. cin>>n>>m;
  8. int array [n+1]={0};
  9. for(int i=0;i<m;i++){
  10. cin>>a>>b>>k;
  11. array[a-1]+= k; array[b]-= k;
  12. }
  13. int cuenta=0,mejor=0;
  14. for (int i=0;i<n+1;i++){
  15. cuenta+=array[i];
  16. if(cuenta>mejor){
  17. mejor = cuenta;
  18. }
  19. }
  20. cout<<mejor;
  21.  
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement