标签:hdu
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4970
5 2 1 3 1 5 5 2 5 1 3 3 1 5 2 7 3 9 1 0
3HintIn the sample, three monsters with origin HP 5, 7 and 9 will survive.
官方题解:http://blog.sina.com.cn/s/blog_6bddecdc0102uzwm.html
代码如下:
//#pragma warning (disable:4786)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <climits>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <deque>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
const double eps = 1e-9;
//const double pi = atan(1.0)*4;
const double pi = 3.1415926535897932384626;
#define INF 1e18
//typedef long long LL;
typedef __int64 LL;
const int MAXN = 200017;
int num[MAXN];
LL sum[MAXN];
int main()
{
int l,r,d;
int tow,n,m,x;
LL h;
while(scanf("%d",&n) && n)
{
scanf("%d",&tow);
memset(num,0,sizeof(num));
memset(sum,0,sizeof(sum));
for(int i = 0; i < tow; i++)
{
scanf("%d%d%d",&l,&r,&d);
num[l] += d;
num[r+1] -= d;
}
for(int i = 1; i <= n; i++)
{
sum[i] = sum[i-1]+num[i];
}
for(int i = n; i >= 1; i--)
{
sum[i] = sum[i+1]+sum[i];
}
int cont = 0;
scanf("%d",&m);
for(int i = 0; i < m; i++)
{
scanf("%I64d%d",&h,&x);
if(sum[x] < h)
{
cont++;
}
}
printf("%d\n",cont);
}
return 0;
}
hdu 4970 Killing Monsters(数学题),布布扣,bubuko.com
hdu 4970 Killing Monsters(数学题)
标签:hdu
原文地址:http://blog.csdn.net/u012860063/article/details/38687837