[Rqnoj-434]LIGNJA
来源:互联网 发布:javascript登录页面 编辑:程序博客网 时间:2024/06/05 20:01
LIGNJA
DP题,最大空闲等于N-最小花费,这个存储方式倒是挺特别。
代码:
type link=^node; node=record x,t:longint; next:link; end;var g:array[1..10001] of link; f:array[1..10001] of longint; n,k:longint;procedure connect(a,t:longint);var p:link;begin new(p); p^.x:=a+t; p^.t:=t; p^.next:=g[a]; g[a]:=p;end;procedure main;var i,a,t:longint; p:link;begin readln(n,k); for i:=1 to k do begin readln(a,t); connect(a,t); end; fillchar(f,sizeof(f),0); for i:=n downto 1 do if g[i]=nil then f[i]:=f[i+1] else begin f[i]:=maxlongint; p:=g[i]; while p<>nil do begin if p^.t+f[p^.x]<f[i] then f[i]:=p^.t+f[p^.x]; p:=p^.next; end; end; write(n-f[1]);end;begin main;end.
- [Rqnoj-434]LIGNJA
- 【動態規劃】尼克的工作日(LIGNJA)
- rqnoj-332 & rqnoj-53
- RQNOJ 164
- RQNOJ 311
- RQNOJ 34
- 决斗 RQNOJ
- rqnoj-153
- rqnoj-394
- rqnoj-3
- rqnoj-12
- rqnoj-93
- rqnoj-4
- rqnoj-1
- rqnoj-2
- rqnoj-20
- rqnoj-15
- rqnoj-16
- 静态链接库与动态链接库
- 一个网络通信开发库源码
- jxl 中 单元格合并,颜色设定等方法
- 汇编学习---循环结构程序设计
- JXL 对excle 操作(单元格合并,列宽,格式等)《二》
- [Rqnoj-434]LIGNJA
- java报表JXL和POI打印设置
- Eclipse(Myeclipse)安装GoogleGWT
- 参数处理函数getopt
- android 按两次 才退出程序
- GNU C __attribute__ 用法
- 表头固定
- 12c新特性
- C语言和设计模式(备忘录模式)