当前位置:网站首页>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;
}
边栏推荐
- acwing周赛58
- 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
- Visio draws Tai Chi
- Chip debugging of es8316 of imx8mp
- [NOIP2009 普及组] 分数线划定
- After learning classes and objects, I wrote a date class
- C'est un petit résumé de l'étude.
- [try to hack] John hash cracking tool
- RTP GB28181 文件测试工具
- Bubble sort
猜你喜欢
Embedded development program framework
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
ISP学习(2)
Distributed transaction solution
Programmers' position in the Internet industry | daily anecdotes
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
Codeforces Round #804 (Div. 2)
Mysql database storage engine
【LGR-109】洛谷 5 月月赛 II & Windy Round 6
随机推荐
Leetcode 186 Flip the word II in the string (2022.07.05)
Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
npm命令--安装依赖包--用法/详解
二叉树基本知识和例题
2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
SharedPreferences source code analysis
Flink kakfa data read and write to Hudi
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
Supreme Court, judgment standard of divorce cases
Dynamic programming (tree DP)
It is also a small summary in learning
flink sql 能同时读多个topic吗。with里怎么写
几种RS485隔离通讯的方案介绍
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
Redis has four methods for checking big keys, which are necessary for optimization
Delete subsequence < daily question >
行业专网对比公网,优势在哪儿?能满足什么特定要求?
Word cover underline
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
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