Advertisement
tumaryui

Untitled

Mar 29th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define endl "\n"
  4. using namespace std;
  5.  
  6. const int N = 1e5 + 10;
  7. int l[N], r[N], d[N], hp[N], x[N];
  8. int suff[N], a[N];
  9. int n, m, k;
  10.  
  11. main() {
  12. ios_base::sync_with_stdio(0);
  13. cin.tie(0);
  14. cout.tie(0);
  15.  
  16. cin >> n >> m;
  17. for(int i = 1; i <= m; i++) {
  18. cin >> l[i] >> r[i] >> d[i];
  19. a[l[i]] += d[i];
  20. a[r[i] + 1] -= d[i];
  21. }
  22.  
  23. for(int i = 1, cur = 0; i <= n; i++) {
  24. cur += a[i];
  25. a[i] = cur;
  26. }
  27. for(int i = n; i >= 1; i--) {
  28. suff[i] = suff[i + 1] + a[i];
  29. }
  30. cin >> k;
  31. for(int i = 1; i <= k; i++) {
  32. cin >> hp[i] >> x[i];
  33. }
  34. int ans = 0;
  35. for(int i = 1; i <= k; i++) {
  36. if(hp[i] > suff[x[i]]) {
  37. ans++;
  38. }
  39. }
  40. cout << ans;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement