JZOJ 5432 三元组
来源:互联网 发布:java 成功生成文件夹 编辑:程序博客网 时间:2024/05/29 04:09
三元组
来自
Description
给出
每一个三元组最多只能选择一个数(即
给出三个要求:
1、选择
2、选择
3、选择
问选出的数的和最大为多少。
Data Constraint
Solution
考虑若
因而对于三元组,可以先强制选择所有的
设新的二元组为(
将
考虑枚举最后选择
使用同样的方法,将
对于维护一些数中的前
Code
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define fo(i,j,l) for(int i=j;i<=l;i++)#define fd(i,j,l) for(int i=j;i>=l;i--)using namespace std;typedef long long ll;const ll N=55e4,M=2*N;struct note{ ll y,z;}t[N];int X,Y,Z;ll x[N],t1[3*N],t2[3*N];int n,m,j,k,l,i,o,p;int max(int a,int b){if(a>b)return a;else return b;}int read(){ int o=0; char ch=' '; for(;ch<'0'||ch>'9';)ch=getchar(); for(;ch>='0'&&ch<='9';ch=getchar())o=o*10+ch-48; return o;}bool kmp(note a,note b){return a.y!=b.y ? a.y>b.y : a.z<b.z ;}int main(){ cin>>X>>Y>>Z; n=X+Y+Z; fo(i,1,n)x[i]=read(),t[i].y=read(),t[i].z=read(); ll ans=0,da=0; fo(i,1,n)da+=x[i],t[i].y-=x[i],t[i].z-=x[i]; sort(t+1,t+n+1,kmp); ll dq=0,op=0,u=0,zd=M+N-10,v=0; fo(i,1,Y)t1[t[i].z-t[i].y+M]++,dq+=t[i].y; fo(i,Y+1,n)t2[t[i].z+M]++; for(;!t1[zd];)zd--; v=t1[zd]; t1[zd]=0; int rr=M+N-10,sx=Z; while(t2[rr]<sx)op+=t2[rr]*(rr-M),sx-=t2[rr],rr--; u=rr; op+=sx*(rr-M); t2[rr]=0; ans=op+dq; fo(i,Y+1,Y+Z){ dq+=t[i].y; ll tt=t[i].z-t[i].y+M; if(tt>zd)dq+=tt-M; else if(tt==zd)dq+=tt-M; else { t1[tt]++; dq+=zd-M; v--; if(!v){ for(;!t1[zd];)zd--; v=t1[zd]; t1[zd]=0; } } tt=t[i].z+M; if(tt>u)op-=tt-M,t2[tt]--; else { sx--,op-=u-M; if(!sx){ for(;!t2[u];)u++; sx=t2[u]; t2[u]=0; } } ans=max(ans,dq+op); } printf("%lld",ans+da);}
阅读全文
1 0
- 【JZOJ 5432】 三元组
- JZOJ 5432 三元组
- 【JZOJ 5432】【NOIP2017提高A组集训10.28】三元组
- JZOJ 5432. 【NOIP2017提高A组集训10.28】三元组
- 三元组
- 数据结构之三元组
- 数据结构实现三元组
- 【其他】【RQNOJ】三元组
- 权限三元组
- [三元组]题解
- 三元组--数据结构
- 毕达哥拉斯三元组
- 三元组最小距离
- "等差三元组"
- 数据结构三元组
- 最小三元组距离
- 毕达哥斯拉三元组poj1305
- 三元组距离最小
- kafka学习笔记
- 分治法
- Marvell交换机luaCLI引擎启动流程以及如何解决函数cpssInitSystem()被二次调用的问题
- WEBADI日记账导入操作
- Make shotcut to VS solution files with python
- JZOJ 5432 三元组
- 两相四线步进电机的驱动
- Java新特性之try-with-resources实践
- codevs2245 股票趋势 ( 二维线段树+dp )
- ubuntu安装TensorFlow及编辑器pycharm
- webstorm安装
- SSL2811 2017年10月30日提高组T2 摘Galo(树形dp)
- 对java super 学习理解
- html5 新增的语义化标签