【BZOJ】4721: [Noip2016]蚯蚓
来源:互联网 发布:java商城项目描述 编辑:程序博客网 时间:2024/04/29 08:25
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4721
先切出来的长的那段不会短于后切出来的长的(短的同样也成立)
所以每次被切的时候把长的扔进一个数组,短的扔进一个数组。这样数组就是有序的了。
然后每次从三个数组头找最大的切就好了。
输出格式:行末无空格,第二行无回车
#include<stdio.h>#include<algorithm>#include<iostream>#define Void inline void#define cint const int &#define cbool const bool &#define N 7100005using namespace std;typedef long long ll;int ha,ta,hb,tb,hc,tc,a[N],b[N],c[N],tm,opt[N],Ta[N],Tb[N],Tc[N],n,m,q,u,v,t,ed,st=1;inline int cal(cint p){ if (p==1) return ha<ta?a[ha+1]+q*(tm-Ta[ha+1]):-1; if (p==2) return hb<tb?b[hb+1]+q*(tm-Tb[hb+1]):-1; if (p==3) return hc<tc?c[hc+1]+q*(tm-Tc[hc+1]):-1;}Void PlanB(cint k,cbool f){ int g=cal(k),p1=(ll)g*u/v,p2=g-p1; if (f) opt[++ed]=g; if (p1<p2) swap(p1,p2); b[++tb]=p1;Tb[tb]=tm+1; c[++tc]=p2;Tc[tc]=tm+1;}Void pf(cint k,cbool f){if (f) opt[++ed]=cal(k);}Void solve(cbool f,cbool op){ int k1=cal(1),k2=cal(2),k3=cal(3); if (k2<=k1 && k3<=k1) (op?PlanB(1,f):pf(1,f)),ha++; else if (k3<=k2) (op?PlanB(2,f):pf(2,f)),hb++; else (op?PlanB(3,f):pf(3,f)),hc++; if (f) st=0;}Void out(){ for (int i=1;i<ed;i++) printf("%d ",opt[i]); if (ed) printf("%d",opt[ed]); ed=0;st=1;}int main(){ scanf("%d%d%d%d%d%d",&n,&m,&q,&u,&v,&t); for (int i=1;i<=n;i++) scanf("%d",a+i);ta=n; sort(a+1,a+n+1,greater<int>()); for (int i=0;i<m;i++,st++) tm=i,solve(t==st,1);tm=m;out();printf("\n"); for (int i=1;i<=n+m;i++,st++) solve(t==st,0);out();}
0 0
- 【BZOJ】4721: [Noip2016]蚯蚓
- BZOJ 4721: [Noip2016]蚯蚓 乱搞
- bzoj 4721: [Noip2016]蚯蚓 单调队列
- BZOJ 4721 [Noip2016]蚯蚓 单调队列
- 4721: [Noip2016]蚯蚓
- NOIP2016蚯蚓
- NOIP2016 蚯蚓
- [noip2016]蚯蚓
- [NOIP2016] 蚯蚓
- NOIP2016蚯蚓
- 【noip2016】蚯蚓
- BZOJ4721 [Noip2016]蚯蚓
- 【NOIP2016】洛谷2827 蚯蚓
- 【NOIP2016提高组】蚯蚓
- noip2016 d2t2 切蚯蚓
- NOIP2016 D2T2 蚯蚓
- noip2016 蚯蚓 智商题
- bzoj4721 [Noip2016]蚯蚓
- abstract类
- pthread_create
- java用poi 生成excel并单元格,字体,样式
- Android丨编写XML控制布局
- 案例解析|政府信息化的BI建设应用
- 【BZOJ】4721: [Noip2016]蚯蚓
- Centos下安装并配置ODBC连接MySQL 【转】
- 如何捕获java线程中的逃逸的异常
- Makefile 中:= ?= += =的区别
- Android 广播内部机制详解(一)
- Glide使用详解(二)
- java 深拷贝 浅拷贝
- 为什么看起来简单的服务,却需要大量顶尖高手来开发?
- 阿里巴巴Java开发手册评述