| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不知道哪里错了,和网上标程对拍半天都是一样的,交上去还是watype
arr=record
whereup,wheredown,x,y,z:int64;
end;
arr1=record
u,v:int64;
end;
arr2=record
ans,lazy:int64;
end;
var
a:array[0..40001] of arr;
orderx:array[0..80001] of arr1;
tree:array[0..200000] of arr2;
n,i,j,k,tot,t:longint;
maxx,maxy,s,d:int64;
function max(a,b:int64):int64;
begin
if a>b then exit(a)
else exit(b);
end;
procedure swap(var a,b:int64);
var
c:int64;
begin
c:=a;
a:=b;
b:=c;
end;
procedure sort1(l,r: longint);
var i,j: longint;
x:int64;
begin
i:=l;j:=r;x:=orderx[(l+r) div 2].u;
repeat
while orderx[i].u<x do inc(i);
while x<orderx[j].u do dec(j);
if not(i>j)
then begin
swap(orderx[i].u,orderx[j].u);
swap(orderx[i].v,orderx[j].v);
inc(i);dec(j);
end;
until i>j;
if l<j then sort1(l,j);
if i<r then sort1(i,r);
end;
procedure sort2(l,r: longint);
var i,j: longint;
x:int64;
begin
i:=l;j:=r;x:=a[(l+r) div 2].x;
repeat
while a[i].x<x do inc(i);
while x<a[j].x do dec(j);
if not(i>j)
then begin
swap(a[i].x,a[j].x);
swap(a[i].y,a[j].y);
swap(a[i].z,a[j].z);
swap(a[i].whereup,a[j].whereup);
swap(a[i].wheredown,a[j].wheredown);
inc(i);dec(j);
end;
until i>j;
if l<j then sort2(l,j);
if i<r then sort2(i,r);
end;
procedure add(sub,dep,left,right,l,r:int64);
var
mid:int64;
begin
if (left=l)and(right=r) then
begin
inc(tree[dep].lazy,sub);
inc(tree[dep].ans,sub);
exit;
end;
mid:=(left+right) div 2;
if tree[dep].lazy<>0 then
begin
inc(tree[dep*2].ans,tree[dep].lazy);
inc(tree[dep*2].lazy,tree[dep].lazy);
inc(tree[dep*2+1].ans,tree[dep].lazy);
inc(tree[dep*2+1].lazy,tree[dep].lazy);
tree[dep].lazy:=0;
end;
if l>=mid+1 then add(sub,dep*2+1,mid+1,right,l,r)
else if r<=mid then add(sub,dep*2,left,mid,l,r)
else
begin
add(sub,dep*2,left,mid,l,mid);
add(sub,dep*2+1,mid+1,right,mid+1,r);
end;
tree[dep].ans:=max(tree[dep*2].ans,tree[dep*2+1].ans);
end;
begin
while not eof do
begin
readln(n,maxx,maxy);
fillchar(tree,sizeof(tree),0);
for i:=1 to n do
with a[i] do
begin
read(x,y,z);
whereup:=i*2;
wheredown:=i*2-1;
orderx[i*2-1].u:=y;
orderx[i*2-1].v:=2*i-1;
orderx[i*2].u:=y+maxy;
orderx[i*2].v:=2*i;
end;
if (maxy=0) then
begin writeln(0); continue; end;
sort1(1,2*n);
d:=orderx[1].u;
orderx[1].u:=orderx[1].v;
orderx[1].v:=1;
for i:=2 to 2*n do
if orderx[i].u=d then
begin orderx[i].u:=orderx[i].v; orderx[i].v:=orderx[i-1].v; end
else
begin
d:=orderx[i].u;
orderx[i].u:=orderx[i].v;
orderx[i].v:=orderx[i-1].v+2;
end;
tot:=orderx[2*n].v;
sort1(1,2*n);
sort2(1,n);
i:=1;
t:=1;
s:=0;
while i<=n do
begin
j:=i;
while (i<=n)and(a[i].x-a[t].x<maxx) do inc(i);
for k:=j to i-1 do
add(a[k].z,1,1,tot,orderx[a[k].wheredown].v+1,orderx[a[k].whereup].v);
s:=max(s,tree[1].ans);
j:=t;
while (t<i)and(a[t].x=a[j].x) do inc(t);
for k:=j to t-1 do
add(-a[k].z,1,1,tot,orderx[a[k].wheredown].v+1,orderx[a[k].whereup].v);
end;
writeln(s);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator