Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. #define ll long long
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     ll int cant, act, maximo = 0, t = 0;
  11.  
  12.     cin >> cant >> act;
  13.  
  14.     vector <ll int> n(cant + 1);
  15.  
  16.     for(ll int i = 0; i < act; i++){
  17.         ll int d, h, k;
  18.  
  19.         cin >> d >> h >> k;
  20.  
  21.         n[d] += k;
  22.         n[h + 1] -= k;
  23.     }
  24.  
  25.     for(ll int i = 1; i <= cant; i++)
  26.         t += n[i], maximo = max(maximo, t);
  27.  
  28.     cout << maximo << endl;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement