栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3075 Ticket

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3075 Ticket

#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;const int N=100005;const long long inf=(long long )N*(long long )N;long long a[N],f[N],t[N],q[N];int main(){ int n,l,r,i,x,y; long long k,ans,p; while (scanf("%d%d%d%lld",&n,&l,&r,&p)==4) { for (i=1; i<=n; i++) scanf("%lld",&a[i]); k=a[1]; for (i=2; i<=n-l; i++) { f[i]=k; if (k+p<a[i]) k+=p; else k=a[i]; } k=a[n]; for (i=n-1; i>=l+1; i--) { t[i]=k; if (k+p<a[i]) k+=p; else k=a[i]; } x=1; y=0; ans=inf; for (i=l+1; i<=n-1; i++) { while (y>=x && f[q[y]]>f[i-l+1]) y--; q[++y]=i-l+1; while (q[x]<i-r+1) x++; ans=min(ans,f[q[x]]+t[i]); } printf("%lldn",ans); }}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/376874.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号