当前位置:网站首页>【暑期每日一题】洛谷 P3156 【深基15.例1】询问学号
【暑期每日一题】洛谷 P3156 【深基15.例1】询问学号
2022-08-02 06:07:00 【AC_Dragon】
题目链接:P3156 【深基15.例1】询问学号 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目描述
有 n(n <= 2×10^6) 名同学陆陆续续进入教室。我们知道每名同学的学号(在 1 到 10^9 之间),按进教室的顺序给出。上课了,老师想知道第 i 个进入教室的同学的学号是什么(最先进入教室的同学 i=1),询问次数不超过 10^5 次。
输入格式
第一行 2 个整数 n 和 m,表示学生个数和询问次数。
第二行 n 个整数,表示按顺序进入教室的学号。
第三行 m 个整数,表示询问第几个进入教室的同学。
输出格式
输出 m 个整数表示答案,用换行隔开。
样例 #1
样例输入 #1
10 3
1 9 2 60 8 17 11 4 5 14
1 5 9样例输出 #1
1
8
5AC code:
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 2e6 + 10;
int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
while(m--)
{
int x;
cin>>x;
cout<<a[x]<<endl;
}
return 0;
}边栏推荐
- 数据库概论-MySQL的数据表的基本操作
- CAT1 4G+Ethernet development board Tencent cloud mobile phone WeChat applet display temperature and delivery control
- MySQL driver jar package download -- nanny tutorial
- Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
- 8/1 思维+扩展欧几里得+树上dp
- MySQL (3)
- chrome 插件开发指南
- Specified URL is not reachable,caused by :‘Read timed out
- Leading the demand and justifying the HR value - the successful launch of the "Human Resource Leading Model HRLM"
- Detailed explanation of 9 common reasons for MySQL index failure
猜你喜欢

推出 Space On-Premises (本地部署版) Beta 版!

看图就懂|衡量业务增长健康的销售指标如何选择

CAT1 4G+以太网开发板腾讯云手机微信小程序显示温度和下发控制

HCIP 第四天

mysql索引失效的常见9种原因详解

Nodejs installation tutorial

MySQL - Multi-table query and case detailed explanation

typescript 'props' is declared but its value is never read solution

Nacos installation configuration and single-machine deployment tutorial

数据库概论-MySQL的数据表的基本操作
随机推荐
Difference between npm and yarn
Kind of weird!Access the destination URL, the host can container but not
Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?
MySQL高级SQL语句(二)
CAT1 4G+Ethernet development board Tencent cloud mobile phone WeChat applet display temperature and delivery control
How the Internet of Things is changing the efficiency of city operations
DNS resolution process
MySQL 5.7 installation tutorial (full-step, nanny-level tutorial)
Node installation and environment configuration
【npm install 报错问题合集】- npm ERR! code ENOTEMPTY npm ERR! syscall rmdir
Connection reset by peer 问题解析
About the local server problem after ue4.27 pixel streaming package
MySQL Index Common Interview Questions (2022 Edition)
Py's mlxtend: a detailed guide to the introduction, installation, and usage of the mlxtend library
MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
数据库概论之MySQL表的增删改查1
HCIP BGP Comprehensive Experiment Establishing peers, route reflectors, federation, route announcement and aggregation
(笔记整理未完成)【图论】图的遍历
HCIP 第四天
享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世