hdu 4970

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=4970

#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

const int M = 100000 + 10;

long long a[M];

int main()
{
	long long n, m, l, r, d;
	long long k, h, x;
	while(~scanf("%I64d", &n), n)
	{
		memset(a, 0, sizeof(a));
		scanf("%I64d", &m);
		for(int i = 1;i <= m;i ++)
		{
			scanf("%I64d%I64d%I64d", &l ,&r ,&d);
			a[l] += d;
			a[r+1] -= d;
		}
		for(int i = 1;i <= n;i ++)
		{
			a[i] += a[i-1];
		}
		for(int i = n-1;i >= 1;i --)
		{
			a[i] += a[i+1];
		}
		long long ans = 0;
		scanf("%I64d", &k);
		for(int i = 0; i < k; i++)
		{
			scanf("%I64d%I64d", &h, &x);
			if(a[x] < h)
				ans ++;
		}
		printf("%I64d\n", ans);
	}
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章