bzoj4717 改装 模拟+二分
Description
Input
Output
暴力吧,100s随便搞
二分
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstdio> #define N 100007
#define inf 1000000007
#define ll long long
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=(x<<)+(x<<)+ch-'';ch=getchar();}
return x*f;
} int n,m,q;
int a[],b[N],cnt[]; inline int jud(int x,int l,int r)
{
int res=;
for(int i=l;i<=r;++i)
{
if(x/b[i]>) continue;
res+=cnt[]-cnt[x/b[i]];
}
return res;
}
int main()
{
freopen("fzy.in","r",stdin);
freopen("fzy.out","w",stdout); n=read();m=read();
for(int i=;i<=n;++i) a[i]=read();
for(int i=;i<=m;++i) b[i]=read();
q=read();
while(q--)
{
int op=read();
if(!op)
{
int type=read(),x=read(),y=read();
if(type) b[x]=y;else a[x]=y;
}
else
{
int l1=read(),r1=read(),l2=read(),r2=read(),k=read();
for(int i=;i<=;++i) cnt[i]=;
for(int i=l1;i<=r1;++i) cnt[a[i]]++;
for(int i=;i<=;++i) cnt[i]+=cnt[i-];
int l=,r=;
while(l<=r)
{
int mid=(ll)l+r>>;
if(jud(mid,l2,r2)>=k) l=mid+;
else r=mid-;
}
printf("%d\n",r+);
}
}
}
bzoj4717 改装 模拟+二分的更多相关文章
- FZU 1575 小学生的游戏【模拟二分】
某天,无聊的小斌叫上几个同学玩游戏,其中有比较笨的小兴,比较傻的小雪,可爱的小霞和自以为是的小楠.他们去找聪明的小明去给他们当裁判.判定谁取得游戏胜利. 而这个游戏是由小斌想个1到10000000的数 ...
- Hdu3640-I, zombie(模拟+二分)
The "endless" model in "I, zombie" of "Plants vs. Zombies" is my favou ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- UVALive 3971 Assemble(模拟 + 二分)
UVALive 3971 题意:有b块钱.想要组装一台电脑,给出n个配件的种类,名字,价格,品质因子.若各种类配件各买一个,总价格<=b,求最差品质配件的最大品质因子. 思路: 求最大的最小值一 ...
- Largest Allowed Area【模拟+二分】
Largest Allowed Area 题目链接(点击) 题目描述 A company is looking for land to build its headquarters. It has a ...
- Codeforces Round #481 (Div. 3) C. Letters (模拟,二分)
题意:有个\(n\)个公寓,每个公寓\(a_{i}\)代表着编号为\(1-a_{i}\)个房间,给你房间号,问它在第几栋公寓的第几个房间. 题解:对每个公寓的房间号记一个前缀和,二分查找属于第几个公寓 ...
- 模拟+二分 poj-1019-Number Sequence
题目链接: http://poj.org/problem?id=1019 题目大意: Sk表示123...k 把S1S2S3...Sk排成一行 比如:112123123412345123456.... ...
- Codeforces 404E: Maze 1D(二分)
题意:指令“R”机器人会向右走一步,“L”是向左.起初机器人在0位置,可以在除了0以外的任何位置放障碍,如果机器人的指令将使它走到障碍上,那这一步他会保持不动.要求让机器人最终结束的那一步一定只走过一 ...
- NOIP模拟测试7
期望得分:60+60+60 实际得分:60+60+0 这次考试主要是T3搜索打挂了(我可是靠搜索吃饭的); 1.数组开小了,不过开大数组只拿到了10分的好成绩. 2.题意没审清(其实是他没说清). 以 ...
随机推荐
- 【0624课外作业】将一个double类型的小数,四舍五入保留两位小数
package com.work0624; /** * 课外作业 *将一个double类型的小数,四舍五入保留两位小数 * @author L * */ import java.util.Scanne ...
- c++ 创建路径方法
linux.unix平台 #include "stdio.h" #include "stdlib.h" #include <sys/types.h> ...
- (转发)IOS动画中的枚举UIViewAnimationOptions
若本帖转自(博客园·小八究):http://www.cnblogs.com/xiaobajiu/p/4084747.html 可怜目前天朝搜不到什么有价值的东西方便学习,在这里方便初学者. 首先这个枚 ...
- iOS应用架构谈part4-本地持久化方案及动态部署
前言 嗯,你们要的大招.跟着这篇文章一起也发布了CTPersistance和CTJSBridge这两个库,希望大家在实际使用的时候如果遇到问题,就给我提issue或者PR或者评论区.每一个issue和 ...
- 如何挂载一个镜像文件(how to mount an image file)
如何挂载一个镜像文件(how to mount an image file) 08/16/2012master 4 Comments 在使用KVM或Xen虚拟化的情况下,经常需要使用镜像文件(imag ...
- 洛谷 1571 眼红的Medusa
洛谷 1571 眼红的Medusa 虽说这道题标签里写明了二分,然而我还是首先想到了map......毕竟map真的是简单好写. map做法 #include<bits/stdc++.h> ...
- pandas关联mysql并读写数据库
1.代码读写mysql,必须安装关联mysql的工具 操作如下命令: sudo apt-get install mysql-server mysql-clientsudo apt-get instal ...
- salt常用模块
salt 常用命令整理 转载:https://www.cnblogs.com/aslongas/p/6964890.html salt 常用命令整理 ***********模块******** ...
- Python爬虫,爬取实验楼全部课程
目的: 使用requests库以及xpath解析进行实验楼所有课程,存入MySQL数据 库中. 准备工作: 首先安装,requests库,lxml库,以及peewee库.在命令行模式,使用以下命令. ...
- exp分析
1 from pwn import* 2 3 local =1 4 debug = 1 5 6 if local: 7 p = process('./pwn1') 8 else: 9 p = remo ...