当前位置:网站首页>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 Clipboard5 3 1 3 4 6 8 1 6 5 Sample output
Copy to Clipboard1 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;
}边栏推荐
- 【LGR-109】洛谷 5 月月赛 II & Windy Round 6
- Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
- RTP GB28181 文件测试工具
- ue5 小知识 FreezeRendering 查看视锥内渲染的物体
- 也算是學習中的小總結
- Bubble sort
- English Vocabulary - life scene memory method
- Sentinel sliding window traffic statistics
- [Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
- Coreldraw2022 new version new function introduction cdr2022
猜你喜欢

行业专网对比公网,优势在哪儿?能满足什么特定要求?

acwing周赛58

Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code

English Vocabulary - life scene memory method

Weng Kai C language third week 3.1 punch in

Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps

Orm-f & Q object

The underlying structure of five data types in redis

Extension of graph theory

比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
随机推荐
[数学建模] 微分方程--捕鱼业的持续发展
Selection of slow motion function
Codeforces Round #804 (Div. 2)
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
The kernel determines whether peripherals are attached to the I2C address
How does vs change the project type?
Platformio create libopencm3 + FreeRTOS project
Basic explanation of turtle module - draw curve
Complete list of common functions of turtle module
Database - MySQL storage engine (deadlock)
Visio draw fan
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
二叉树基本知识和例题
Supreme Court, judgment standard of divorce cases
Is the mode of education together - on campus + off campus reliable
After learning classes and objects, I wrote a date class
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
Word cover underline
C'est un petit résumé de l'étude.
Distributed transaction solution