- 守望者的逃离
- 2015-10-16 22:34:29 @
评测结果
编译成功
Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
Linking foo.exe
68 lines compiled, 0.1 sec , 29328 bytes code, 1644 bytes data
测试数据 #0: Accepted, time = 15 ms, mem = 772 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 776 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 772 KiB, score = 10
测试数据 #3: RuntimeError, time = 0 ms, mem = 776 KiB, score = 0
测试数据 #4: RuntimeError, time = 0 ms, mem = 772 KiB, score = 0
测试数据 #5: RuntimeError, time = 0 ms, mem = 772 KiB, score = 0
测试数据 #6: RuntimeError, time = 15 ms, mem = 768 KiB, score = 0
测试数据 #7: RuntimeError, time = 0 ms, mem = 772 KiB, score = 0
测试数据 #8: RuntimeError, time = 0 ms, mem = 776 KiB, score = 0
测试数据 #9: Accepted, time = 2 ms, mem = 772 KiB, score = 10
RuntimeError, time = 47 ms, mem = 776 KiB, score = 40
代码
program p1431;
var m,s,t:longint;
cs,ct:longint;
i,j:integer;
dp:array [1..14,0..240] of integer;
function min(a,b:integer):integer;
begin
if a>b then exit(b) else exit(a);
end;
function max(a,b:integer):integer;
begin
if a>b then exit(a) else exit(b);
end;
begin
readln(m,s,t);
cs:=0;
ct:=0;
while m>10 do
begin
inc(cs,60);
inc(ct);
dec(m,10);
if cs>=s then
begin
writeln('Yes');
writeln(ct);
exit;
end;
if ct>=t then
begin
writeln('No');
writeln(cs);
exit;
end;
end;
while (t-ct>14) and (s-cs>240) do
begin
inc(cs,120);
inc(ct,7);
end;
for i:=1 to (t-ct) do
for j:=0 to (s-cs) do
dp[i,j]:=-1;
dp[1,0]:=m+4;
dp[1,min(17,s-cs)]:=m;
for i:=2 to (t-ct) do
for j:=0 to (s-cs) do
if dp[i-1,j]>-1 then
begin
dp[i,j]:=max(dp[i,j],dp[i-1,j]+4);
dp[i,min(j+17,s-cs)]:=max(dp[i,min(j+17,s-cs)],dp[i-1,j]);
if dp[i-1,j]>=10 then
dp[i,min(j+60,s-cs)]:=max(dp[i,min(j+60,s-cs)],dp[i-1,j]-10);
end;
for i:=1 to (t-ct) do
if dp[i,s-cs]>-1 then
begin
writeln('Yes');
writeln(ct+i);
exit;
end;
for i:=(s-cs) downto 0 do
if dp[t-ct,i]>-1 then
begin
writeln('No');
writeln(cs+i);
exit;
end;
end.