/ Vijos /

用户

个人简介

program b1003;
var cost:array[0..100,0..100] of longint;
n,m,k,e,d:longint;
f:array[0..20] of longint;
d1:array[0..1000] of longint;
d2:array[0..20,0..100] of boolean;
//
procedure init;
var i:longint;
begin
assign(input,'b1003.in');assign(output,'b1003.out');
reset(input);rewrite(output);
read(n,m,k,e);
for i:=1 to e do read(d1[i,1],d1[i,2],d1[i,3]);
read(d);
for i:=1 to d do
begin
read(a1,a2,a3);
for j:=a2 to a3 do d2[a1,j]:=true;
end;
end;
//
function max(p1,p2:longint):lonignt;
begin
if p1>p2 then exit(p1)
lese exit(p2);
end;
//
procedure makecost(p1,p2:longint);
var i:longint;
map:array[1..20] of longint;
begin
for i:=1 to n do
for j:=p1 to p2 do if d2[i,j] then map[i,j]:=true;
for i:=1 to n do
begin

end;
end;
//
procedure main;
var i,j:longint;
begin
for i:=1 to n do
for j:=i to n do makecost(i,j);
for i:=1 to n do
begin
f[i]:=n*cost[1,n];
for j:=1 to i-1 do f[i]:=max(f[i],f[j]+k+(i-j)*cost[j+1,i]);
end;
end;
//
begin
init;
main;
write(f[n]);
close(output);
end.