博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
uva 1451(树形结合)
阅读量:4654 次
发布时间:2019-06-09

本文共 907 字,大约阅读时间需要 3 分钟。

求y/x的最大,其实就是求斜率最大

#include 
#include
#include
#include
using namespace std;const int maxn=100000+10;char ss[maxn];int sum[maxn],q[maxn];int n,m,t;int solve(int x1,int x2,int x3,int x4){ return (sum[x2]-sum[x1])*(x4-x3)-(sum[x4]-sum[x3])*(x2-x1);}int main(){ scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); getchar(); scanf("%s",ss+1); getchar(); sum[0]=0; for(int i=1;i<=n;i++) sum[i]=sum[i-1]+ss[i]-'0';//求前缀和,也就是y int i=0,j=0; int ll=0,rr=m; for(int l=m;l<=n;l++)//以l结尾的点 { while(i
0) j--;//维护前端,使其出现凹形 q[j++]=l-m; while(i
<=0) i++;//找到以l为结尾的凹形的切线,前面的点都不要 int mm=solve(ll,rr,q[i],l); if(mm<0||m==0&&(l-q[i]

 

转载于:https://www.cnblogs.com/Wangwanxiang/p/7395569.html

你可能感兴趣的文章
POJ 3723
查看>>
Elgg网站迁移指南
查看>>
Sublime Text 3 及Package Control 安装(附上一个3103可用的Key)
查看>>
基于uFUN开发板的心率计(一)DMA方式获取传感器数据
查看>>
【dp】船
查看>>
oracle, group by, having, where
查看>>
⑥python模块初识、pyc和PyCodeObject
查看>>
nodejs pm2使用
查看>>
CSS选择器总结
查看>>
mysql中sql语句
查看>>
sql语句的各种模糊查询语句
查看>>
C#操作OFFICE一(EXCEL)
查看>>
【js操作url参数】获取指定url参数值、取指定url参数并转为json对象
查看>>
移动端单屏解决方案
查看>>
web渗透测试基本步骤
查看>>
使用Struts2标签遍历集合
查看>>
angular.isUndefined()
查看>>
第一次软件工程作业(改进版)
查看>>
网络流24题-飞行员配对方案问题
查看>>
Jenkins 2.16.3默认没有Launch agent via Java Web Start,如何配置使用
查看>>