当前位置:网站首页>Biscuits (examination version)
Biscuits (examination version)
2022-07-06 04:47:00 【Recurss】
Background
One thirty in the morning , The day is just dawning ,ly On the battlefield , No lunch , Hungry, he dug out a bag of biscuits from his pencil box ......
This bag of biscuits has n block , They are respectively called No 1,2...n block , The first i The area of a biscuit is w [i], And w [i] Is strictly rising ( namely w [i + 1] > w [i]).
ly Need to eat s Area of cookies , And he will only choose one piece to eat , Then the block is larger than s The part will be thrown away .
So diligent and thrifty ly Of course, I will choose the biscuit that wastes the least area to eat .
Besides , as everyone knows , Everything will change with the change of many factors , Of course ly The area of cookies to eat s No exception
therefore ly Will ask you q Time : When the area of cookies he needs to eat is s [i] when , Which biscuit should he eat .
( Be careful : Each inquiry is independent , No The first i After the first inquiry , Cookies will disappear ; If more than one biscuit meets the requirements , Output the smallest piece )
Input format
For each test point , There are three lines of input
first line , Enter two positive integers n, q (n, q <= 20'0000),n Indicates the number of cookies ,q Indicates the number of times to ask .
The second line , Input n A positive integer w [i],(w [i] <= 10'0000'0000) It means the first one i The area of a biscuit .
The third line , Input p A positive integer s [i], (s [i] <= 2'0000'0000), Express ly The first i During the first inquiry , The area of cookies to eat .
Output description
Just one line :q A positive integer , The first i The number means ly The first i The number of biscuits to eat in this inquiry .
The sample input
Copy to Clipboard
5 3 1 3 4 6 8 1 6 5
Sample output
Copy to Clipboard
1 4 4
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int INF = 1e9 + 10;
int w[N];
int sum[N];
int n,q;
int main(){
cin >> n >> q;
for(int i = 1;i <= n;i ++){
cin >> w[i];
}
while(q--){
int x;
cin >> x;
int pos = lower_bound(w + 1,w + 1 + n,x) - w - 1;
cout << pos + 1 << " ";
}
cout << endl;
}
边栏推荐
- Can CDC pull the Oracle table in full
- [HBZ share] reasons for slow addition and deletion of ArrayList and fast query
- 树莓派3.5寸屏幕白屏显示连接
- How does vs change the project type?
- [mathematical modeling] differential equation -- sustainable development of fishing industry
- [Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
- Postman关联
- Is the mode of education together - on campus + off campus reliable
- ISP学习(2)
- Basic knowledge and examples of binary tree
猜你喜欢
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[数学建模] 微分方程--捕鱼业的持续发展
[Zhao Yuqiang] deploy kubernetes cluster with binary package
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
Postman关联
Postman前置脚本-全局变量和环境变量
Etcd database source code analysis -- etcdserver bootstrap initialization storage
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
随机推荐
Coreldraw2022 new version new function introduction cdr2022
Ue5 small knowledge points to enable the setting of lumen
Extension of graph theory
flink sql 能同时读多个topic吗。with里怎么写
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
关于es8316的音频爆破音的解决
C'est un petit résumé de l'étude.
Postman测试报告
团队协作出了问题,项目经理怎么办?
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
It is also a small summary in learning
Quick sort
The value of two date types is subtracted and converted to seconds
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
SQL injection vulnerability (MSSQL injection)
The underlying structure of five data types in redis
11. Intranet penetration and automatic refresh
你需要知道的 TCP 三次握手
【Try to Hack】john哈希破解工具
The web project imported the MySQL driver jar package but failed to load it into the driver