当前位置:网站首页>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;
}
边栏推荐
- 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
- [NOIP2008 提高组] 笨小猴
- Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
- Nestjs配置文件上传, 配置中间件以及管道的使用
- Codeforces Round #804 (Div. 2)
- Request (request object) and response (response object)
- RTP GB28181 文件测试工具
- Coreldraw2022 new version new function introduction cdr2022
- ISP学习(2)
- MPLS experiment
猜你喜欢
IPv6 comprehensive experiment
The most detailed and comprehensive update content and all functions of guitar pro 8.0
Visio draws Tai Chi
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
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
ETCD数据库源码分析——etcdserver bootstrap初始化存储
Basic explanation of turtle module - draw curve
SQL injection vulnerability (MSSQL injection)
随机推荐
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
Complete list of common functions of turtle module
The video in win10 computer system does not display thumbnails
Chip debugging of es8316 of imx8mp
Summary of redis AOF and RDB knowledge points
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
[FreeRTOS interrupt experiment]
acwing周赛58
Word cover underline
Tengine kernel parameters
Digital children < daily question> (Digital DP)
Dry goods collection | Vulkan game engine video tutorial
Postman前置脚本-全局变量和环境变量
[NOIP2008 提高组] 笨小猴
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
win10电脑系统里的视频不显示缩略图
Platformio create libopencm3 + FreeRTOS project
How to estimate the population with samples? (mean, variance, standard deviation)
cdc 能全量拉去oracle 表嘛
Use sentinel to interface locally