NOIP11.14 score DP
来源:互联网 发布:服装数据分析文字 编辑:程序博客网 时间:2024/06/15 01:26
傻逼dp,然而我没有对拍,所以挂了。。结果发现是没有取dp的max值。。真的是惨痛的教训。。
代码:
var t,k,p,n,m,j1:int64; i,j:longint; fuck:boolean; ans:int64; f:Array[0..200000]of int64; a,b,c:array[0..200000]of int64; d:Array[0..200000]of real;function max(x,y:int64):int64;begin if x>y then exit(x) else exit(y);end;procedure swap(var x,y:int64);var t:int64;begin t:=x; x:=y; y:=t;end;procedure qsort(l,r:int64);var i,j:int64; m,t:real;begin i:=l; j:=r; m:=d[(l+r)div 2]; repeat while d[i]>m do inc(i); while d[j]<m do dec(j); if i<=j then begin swap(a[i],a[j]); swap(b[i],b[j]); swap(c[i],c[j]); t:=d[i]; d[i]:=d[j]; d[j]:=t; inc(i); dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r);end;begin assign(input,'score.in'); assign(output,'score.out'); reset(input); rewrite(output); readln(t); while t<>0 do begin read(n,m); for i:=1 to n do begin readln(a[i],b[i],c[i]); d[i]:=b[i]/c[i]; end; qsort(1,n); fillchar(f,sizeof(f),0); k:=0; for i:=1 to n do begin for j:=m downto c[i] do begin k:=a[i]-b[i]*j; f[j]:=max(f[j],f[j-c[i]]+k); end; end; for i:=1 to m-1 do f[m]:=max(f[m],f[i]); writeln(f[m]); dec(t); end; close(input); close(output);end.
0 0
- NOIP11.14 score DP
- NOIP11.14&11.15总结
- NOIP11.14模拟 摆书
- hoj Score Sequence DP
- Uva1585-Score-dp
- USACO section 3.1 Score Inflation(DP背包)
- USACO-Section 3.1 Score Inflation(DP)
- Score
- score
- score
- Score
- Score
- Score
- Score
- NOIP11.3总结
- NOIP11.15模拟 T2 三部曲
- Inception Score&Mode Score
- noip11.4分解数 twopointers+欧拉筛
- python技巧(一)
- ruby语言学习
- 类的加载顺序,初始化块
- Sublime使用MarkDown
- 1093. Count PAT's (25)
- NOIP11.14 score DP
- Jquery超简单遮罩层实现代码
- $(this).attr $(this).val
- IOS开发教程 - 如何通过二进制数据上传图片
- <input></input>和<input /> <input>
- 打印菱形字母
- 模板
- android 在init.rc中配置socket及其使用
- python 使用requests 实现 post 和get请求