poj 2018 Best Cow Fences
2012-10-01 13:11
309 查看
题目链接:poj 2018 Best Cow Fences
这么裸的斜率优化,结果果断调试了两个多小时,长时间不复习真是脑残了……
这么裸的斜率优化,结果果断调试了两个多小时,长时间不复习真是脑残了……
#include <iostream> #include <cstdio> #include <cstring> using namespace std; long long f[100100]; int q[100100]; int main() { int n,F,a; while(scanf("%d%d",&n,&F)==2) { for(int i=1;i<=n;i++) { scanf("%d",&a); f[i]=f[i-1]+a; } int l=0,r=0; long long ans=0; for(int i=F;i<=n;i++) { while(l+1<r&&(f[i-F]-f[q[r-1]])*(q[r-1]-q[r-2])<=(f[q[r-1]]-f[q[r-2]])*(i-F-q[r-1])) r--; q[r++]=i-F; while(l+1<r&&(f[i]-f[q[l+1]])*(i-q[l])>=(f[i]-f[q[l]])*(i-q[l+1])) l++; ans=max(ans,(f[i]-f[q[l]])*1000/(i-q[l])); } printf("%lld\n",ans); } return 0; }
相关文章推荐
- poj2018——Best Cow Fences
- POJ 2018 Best Cow Fences (斜率优化入门)
- Best Cow Fences POJ - 2018(经典二分)
- poj 2018 Best Cow Fences
- poj 动态规划DP - 2018 Best Cow Fences
- poj 2018 Best Cow Fences USACO历年月赛 (分数规划+DP)
- POJ 2018 Best Cow Fences 笔记
- POJ - 2018 Best Cow Fences(DP)
- [USACO2003][poj2018]Best Cow Fences(数形结合+单调队列维护)
- POJ 2018 Best Cow Fences
- POJ 2018 Best Cow Fences
- POJ 2018 Best Cow Fences
- POJ2018 Best Cow Fences
- POJ 2018 Best Cow Fences
- 【斜率】【poj 2018】Best Cow Fences
- poj 2018 Best Cow Fences
- POJ 2018 Best Cow Fences
- POJ-2018 Best Cow Fences(二分加DP)
- POJ-2018 Best Cow Fences(二分加DP)
- poj 2018 Best Cow Fences dp+单调队列优化