- 借教室
- 2014-11-03 21:34:33 @
有三个点过不了...怎么破?觉得已经最优了...
var
n,m,i,l,r,now,k,ssum:longint;
room,d,s,t,sum:array[0..1000001]of longint;
flag:boolean;
procedure init;
begin
read(n,m);
for i:=1 to n do
read(room[i]);
for i:=1 to m do
read(d[i],s[i],t[i]);
end;
procedure print;
begin
write(0);
halt;
end;
procedure work;
begin
now:=0;
l:=0;
r:=m+1;
repeat
flag:=true;
k:=(l+r)shr 1;
if k>now then
for i:=now+1 to k do
begin
inc(sum[s[i]],d[i]);
dec(sum[t[i]+1],d[i]);
end
else
for i:=k+1 to now do
begin
dec(sum[s[i]],d[i]);
inc(sum[t[i]+1],d[i]);
end;
now:=k;
ssum:=0;
for i:=1 to n do
begin
inc(ssum,sum[i]);
if ssum>room[i] then begin flag:=false; break; end;
end;
if flag then l:=k+1
else r:=k;
until l=r;
if (k=m)and(flag) then print;
writeln(-1);
write(l);
end;
begin
init;
work;
end.
2 条评论
-
小岛 LV 10 @ 2015-02-24 03:59:37
你是哪几个点没有过。
https://vijos.org/records/?pid=1782&uid=101314我怎么没有看到您所谓“有三个点过不了”的记录?
-
2014-11-03 21:35:06@
好,我来指导指导你
ps:我在逗你
- 1