math与cena之争
【math与cena之争】今天用cena测金陵中学一次竞赛(圣诞赛)……被cena狠狠坑了……
源码:
uses math;
var a:array[1..200] of longint;
f:array[1..200,1..200] of boolean;
n,i,big,j,x:longint;
begin
assign(input,'tree.in');
reset(input);
assign(output,'tree.out');
rewrite(output);
read(n);
fillchar(f,sizeof(f),false);
for i:=1 to n do
begin
read(a[i]);
while not eoln do
begin read(x);
f[x,i]:=true;
end;
big:=0;
for j:=1 to i-1 do
if f[i,j] then big:=max(big,f[i,j]);
a[i]:=a[i]+big;
end;
write(maxvalue(a));
close(input);
close(output);
end .
运行时错误……用不了math单元……
改:
var a:array[1..200] of longint;
f:array[1..200,1..200] of boolean;
n,i,big,j,x:longint;
begin
assign(input,'tree.in');
reset(input);
assign(output,'tree.out');
rewrite(output);
read(n);
fillchar(f,sizeof(f),false);
for i:=1 to n do
begin
read(a[i]);
while not eoln do
begin read(x);
f[x,i]:=true;
end;
big:=0;
for j:=1 to i-1 do
if f[i,j] then if a[j]>big then big:=a[j];
a[i]:=a[i]+big;
end;
big:=0;
for i:=1 to n do if a[i]>big then big:=a[i];
close(input);
close(output);
end .
AC……TAT
转载于:https://www.cnblogs.com/love-saber/p/5907245.html
推荐阅读
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- Docker应用:容器间通信与Mariadb数据库主从复制
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量
- 第326天
- Shell-Bash变量与运算符
- 逻辑回归的理解与python示例
- Guava|Guava RateLimiter与限流算法
- 我和你之前距离
- CGI,FastCGI,PHP-CGI与PHP-FPM
- 原生家庭之痛与超越