poj 2482 挑战 284
来源:互联网 发布:auxre 如何设计软件 编辑:程序博客网 时间:2024/05/16 17:41
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ULL;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const int big=50000;
int max(int a,int b) {return a>b?a:b;};
int min(int a,int b) {return a<b?a:b;};
struct Ne{
int x,y,v;
}ne[10005];
int data[1<<28];
bool cmp(Ne a,Ne b)
{
return a.y<b.y;
}
void build(int k,int l,int r)
{
data[k]=0;
if(r-l==1)
return;
build(2*k+1,l,(l+r)>>1);
build(2*k+2,(l+r)>>1,r);
}
void update(int k)
{
while(k>0)
{
k=(k-1)/2;
data[k]=max(data[2*k+1],data[2*k+2]);
}
}
void add(int k,int a,int b,int l,int r,int v)
{
//cout<<"////3"<<endl;
if(r<=a||l>=b)
{
//printf("1\n");
return;
}
else if(l<=a&&b<=r)
{
data[k]+=v;
update(k);
//printf("2\n");
return;
}
else if(r>a&&l<b)
{
// printf("4\n");
add(2*k+1,a,(a+b)>>1,l,r,v);
add(2*k+2,(a+b)>>1,b,l,r,v);
}
}
int main()
{
int n,a,b,rr;
ne[0].y=0;
while(~scanf("%d %d %d",&n,&a,&b))
{
rr=0;
for(int i=1;i<=n;i++)
{
scanf("%d %d %d",&ne[i].x,&ne[i].y,&ne[i].v);
rr=max(rr,ne[i].x);
}
sort(ne+1,ne+n+1,cmp);
build(0,0,rr+1);
int ans=0,l=0,r=0;
for(;;)
{
//cout<<"///1"<<endl;
while(ne[r].y-ne[l].y<b)
{
r++;
if(r>n)
break;
//cout<<"////2"<<endl;
int k=ne[r].x-a+1;
if(k<0) k=0;
//printf("%d %d\n",k,ne[r].x+a);
add(0,0,rr+1,k,ne[r].x+a,ne[r].v);
ans=max(data[0],ans);
//cout<<"///ans:"<<ans<<endl;
}
if(r>n) break;
add(0,1,rr+1,ne[l].x-a+1,ne[l].x+a,-ne[l].v);
l++;
}
printf("%d\n",ans);
}
return 0;
}
- poj 2482 挑战 284
- 挑战poj
- 挑战 POJ.2991 Crane
- 挑战程序设计竞赛---POJ.2686
- 挑战程序设计竞赛---POJ.3233
- BZOJ2292: 【POJ Challenge 】永远挑战
- 挑战程序设计 DP POJ 3181
- [挑战程序设计竞赛] POJ 3253 - Fence Repair
- [挑战程序设计竞赛] POJ 3009 - Curling 2.0
- [挑战程序设计竞赛] POJ 3699 - Meteor Shower
- [挑战程序设计竞赛] POJ 2718 - Smallest Difference
- [挑战程序设计竞赛] POJ 3050 - Hopscotch
- [挑战程序设计竞赛] POJ 2376 - Cleaning Shifts
- [挑战程序设计竞赛] POJ 1328 - Radar Installation
- [挑战程序设计竞赛] POJ 3040 - Allowance
- [挑战程序设计竞赛] POJ 1862 - Stripies
- POJ 1990 MooFest 题解 《挑战程序设计竞赛》
- 挑战2.1 Hopscotch(POJ 3050)
- poj 3686 The Windy\'s 最小费用流 建图 16_05_14
- poj 3168 Barn Expansion 平面扫描+线段相交问题
- K最短路问题(A*算法)
- Kth Smallest Element in a Sorted Matrix (第十二周 二分法)
- powerdesign preview 中注释语句在column外面解决方法
- poj 2482 挑战 284
- poj 2686 Traveling by Stagecoach 状态压缩
- hdu 3790 最短路模板
- poj 2441
- poj 3154 Corn Fields
- poj 2836 Rectangular Covering
- Codeforces Round #345 (Div. 2) B 思维题
- UVA 11796 Dog Distance 向量+相对运动
- CF 554A 字符串计数问题