bzoj 1668
来源:互联网 发布:crm node online 编辑:程序博客网 时间:2024/05/16 06:54
题意:n*m的矩阵,从(1,1)出发,只能向(i,j+1)、(i-1,j+1)、(i+1,j+1)的格子前进,每个格子有一个权值,求到(n,m)的最大权值和
简单dp,注意要求从(1,1)出发,所以有的点是走不到的,更新的时候判断一下即可
var n,m :longint; i,j :longint; a,f :array[0..110,0..110] of longint;function max(a,b:longint):longint;begin if a<b then exit(b) else exit(a);end;begin read(n,m); for i:=1 to n do for j:=1 to m do read(a[i,j]); f[1,1]:=a[1,1]; for j:=2 to m do for i:=1 to n do begin if f[i-1,j-1]<>0 then f[i,j]:=max(f[i,j],f[i-1,j-1]); if f[i,j-1]<>0 then f[i,j]:=max(f[i,j],f[i,j-1]); if f[i+1,j-1]<>0 then f[i,j]:=max(f[i,j],f[i+1,j-1]); if f[i,j]<>0 then inc(f[i,j],a[i,j]); end; writeln(f[n,m]);end.——by Eirlys
0 0
- bzoj 1668
- [BZOJ ]
- BZOJ****-****
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- BZOJ
- bzoj
- bzoj
- BZOJ
- BZOJ
- bzoj
- try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会不会被执行,什么时候被执行,在return前还是后?
- 申请免费startcom的ssl证书/CA证书
- oracle学习笔记 存储结构_表空间
- 七款出色的Python IDE
- hdu 2896 病毒侵袭(AC自动机)
- bzoj 1668
- Docker for Mac 安装及Mysql安装使用
- Java中字符和byte数组之间的相互转换
- NodeJS-基础入门(一)
- static
- 【HTML】淘宝注册页面
- c# DataView.ToTable() 方法 去除表中的重复项
- 高性能MySQL笔记之数据类型和scheme优化
- Java 序列化全解密