K`th number
来源:互联网 发布:淘宝什么是转化率 编辑:程序博客网 时间:2024/05/16 08:19
二分答案,check()用two point写
#include<iostream>#include<cstdio>#include<algorithm>#define LL long long#define N 200009using namespace std;int n,m;LL k;LL a[N],b[N],num,L,R,mid;bool flag;inline int read() //读入优化 { int f=1,p=0;char c=getchar(); while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();} return f*p; }bool check(LL x)//小于等于 { LL tot=0; int t1=1,t2=m; while(t1<=n)//two point { while(a[t1]*b[t2]>x&&t1<=n&&t2>=1) t2--; tot+=t2; t1++; } return tot<k;//注意判定条件!}int main(){ scanf("%d%d%lld",&n,&m,&k); for(int i=1;i<=n;i++) scanf("%lld",&a[i]); for(int i=1;i<=m;i++) scanf("%lld",&b[i]); sort(a+1,a+n+1);sort(b+1,b+m+1); L=1,R=a[n]*b[m]; while(L<=R) { mid=(L+R)>>1; if(check(mid)) L=mid+1; else R=mid-1; } printf("%lld\n",L); return 0;}
阅读全文
1 0
- Pku2104 k - th number
- [poj2104]K-th Number
- [Poj2104]K-th Number
- [POJ2104]K-th Number
- poj2104 K-th Number
- poj2104 K-th Number
- 【bzoj2104】 K-th Number
- POJ2104-K-th Number
- poj2104 K-th Number
- POJ2104:K-th Number
- poj2104 K-th Number
- 2104 -- K-th Number
- POJ2104 k-th number
- 【poj2104】K-th Number
- poj2104 K-th Number
- Poj2104 K-th Number
- poj2124:K-th Number
- poj2104 K-th Number
- Numpy常用函数sum, shape, reshape, argsort, tile,where
- linux环境安装jdk ,tomcat
- Scala-Actor并行wordcount
- 屏幕高度的获取以及高度的自适应问题
- FreeMarker 生成合同
- K`th number
- framework dyld: Symbol not found: _OBJC_CLASS_xxx
- Java集合及concurrent并发包总结
- Javascript中的按值传递与引用传递
- android图片二次采样(缩略图)
- css隐藏滚动条
- LSTM梳理、理解和Keras实现
- spring及springMVC及web.xml通配
- POJ1062 昂贵的聘礼(枚举系列的dijkstra)