poj 2018 Best Cow Fences
来源:互联网 发布:淘宝突然没有生意 编辑:程序博客网 时间:2024/04/29 18:15
题目链接: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;}
- 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
- 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 笔记
- poj 2018 Best Cow Fences 二分查找dp
- poj 2018 Best Cow Fences dp+单调队列优化
- poj 动态规划DP - 2018 Best Cow Fences
- POJ 2018 Best Cow Fences (斜率优化入门)
- POJ-2018 Best Cow Fences(二分加DP)
- Poj 2018 Best Cow Fences(分数规划+DP&&斜率优化)
- poj2018 Best Cow Fences
- poj2018 Best Cow Fences
- Adapter模式
- poj2689 Prime Distance 素数筛选应用 复习
- POJ3067
- Static 静态成员函数 和 static成员的访问 【C++ static】
- windows 控制台下运行cl命令
- poj 2018 Best Cow Fences
- 黑马程序员--11集合类的学习List&Hash&Array)Set&泛型
- ZOJ 3380 Patchouli's Spell Cards(DP,大数)
- javaSE学习笔记5——访问控制权限private、default、protected、public
- 启动 tws 中间件后,发现 端口 31116 没有开
- 汇编语言超浓缩教程
- 网站title/keywords/description的编写原则
- Friend 非成员函数声明为友元 【C++ friend】
- javaSE学习笔记6 重写