当前位置:网站首页>【暑期每日一题】洛谷 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 driver jar package download -- nanny tutorial
- HCIP 第三天实验
- MySQL高级SQL语句(二)
- File upload vulnerability (2)
- zabbix auto-discovery and auto-registration
- Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?
- MySQL - 多表查询与案例详解
- MySql COUNT statistics function explanation
- 武汉高性能计算大会2022举办,高性能计算生态发展再添新动力
- aTrust项目的相关操作与分享
猜你喜欢

Clapper that can interact with the audience in real time

Leading the demand and justifying the HR value - the successful launch of the "Human Resource Leading Model HRLM"

有点奇怪!访问目的网址,主机能容器却不行

Reverse resolve dns server

振兴农村循环经济 和数链串起农业“生态链”

【21天学习挑战赛】顺序查找

PMP新考纲通关秘籍,告别抓瞎

MySQL高级语句(一)

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

The stock price has repeatedly hit new lows, and the real estate SaaS giant is in trouble. How should Mingyuan Cloud transform and save itself?
随机推荐
推出 Space On-Premises (本地部署版) Beta 版!
DNS resolution process
Node installation and environment configuration
笔记本开机黑屏提示:ERROR 0199:System Security-Security password retry count exceeded
C# Coding Conventions Handbook
提交代码流程
宝塔+FastAdmin 404 Not Found
HCIP day one
.NET Static Code Weaving - Rougamo Release 1.1.0
Toolbox App 1.25 New Features at a Glance | Version Update
ue先视频教程后深入
How does abaqus quickly import the assembly of other cae files?
Nodejs安装教程
MySQL - 多表查询与案例详解
MySQL高阶---存储引擎、索引、锁
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
Two good php debug tutorials
The second day HCIP
专家见解|经济低迷期把握创新机会的 3 大方法
数据库概论之MySQL表的增删改查1