Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- #define endl "\n"
- using namespace std;
- const int N = 1e5 + 10;
- int l[N], r[N], d[N], hp[N], x[N];
- int suff[N], a[N];
- int n, m, k;
- main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin >> n >> m;
- for(int i = 1; i <= m; i++) {
- cin >> l[i] >> r[i] >> d[i];
- a[l[i]] += d[i];
- a[r[i] + 1] -= d[i];
- }
- for(int i = 1, cur = 0; i <= n; i++) {
- cur += a[i];
- a[i] = cur;
- }
- for(int i = n; i >= 1; i--) {
- suff[i] = suff[i + 1] + a[i];
- }
- cin >> k;
- for(int i = 1; i <= k; i++) {
- cin >> hp[i] >> x[i];
- }
- int ans = 0;
- for(int i = 1; i <= k; i++) {
- if(hp[i] > suff[x[i]]) {
- ans++;
- }
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement