Advertisement
Guest User

task966

a guest
Feb 27th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #define loop(i,from,to) for (int i = from; i < to; ++i)
  2. #define qAll(q) q.begin(), q.end()
  3. #include <bits/stdc++.h>
  4.    
  5. using std::cin;
  6. using std::cout;
  7. using std::endl;
  8. using std::vector;
  9. using std::string;
  10. using std::pair;
  11. using std::set;
  12.  
  13. const int INF = 1e9+7;
  14. const double eps = 1e-6;
  15. template <typename T> void reverse(T &a) {
  16.   long long s = a.size();
  17.   for (long long i = 0; i < s / 2; ++i)
  18.     std::swap(a[i], a[s - i - 1]);
  19. }
  20.  
  21.  
  22. signed main() {
  23.   std::ios::sync_with_stdio(false);
  24.   cin.tie(0);
  25.   cout.tie();
  26.  
  27.   int n, l, r, v, t; cin >> n;
  28.   vector< vector<int> > data(n);
  29.   loop(i, 0, n) {
  30.     cin >> l >> r >> v;
  31.     data[i].emplace_back(l);
  32.     data[i].emplace_back(r);
  33.     data[i].emplace_back(v);
  34.   }
  35.   cin >> t;
  36.   vector<int> timeline(t, 0);
  37.  
  38.   std::sort(data.begin(), data.end());
  39.   loop(i, 0, n)
  40.     loop(j, data[i][0], t - 1) {
  41.       if (j > data[i][1]) break;
  42.       timeline[j] += data[i][2];
  43.     }
  44.   cout << timeline[t - 1];
  45.   //std::cout << "Hello World!\n";
  46.   return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement