当前位置:网站首页>【暑期每日一题】洛谷 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;
}边栏推荐
- ASP.NET Core Web API 幂等性
- APP专项测试:流量测试
- MySQL high-level --- storage engine, index, lock
- Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
- Nacos installation detailed process
- Nodejs installation and global configuration (super detailed)
- 解决:- SPY: No data found for this date range, symbol may be delisted报错
- HCIP day one
- PHP Warning: putenv() has been disabled for security reasons in phar
- chrome plugin development guide
猜你喜欢

Pagoda+FastAdmin 404 Not Found

MySQL driver jar package download -- nanny tutorial

Toolbox App 1.25 新功能一览 | 版本更新

HCIP day 3 experiment

数据库概论-MySQL的数据表的基本操作

MySQL Index Common Interview Questions (2022 Edition)

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

View source and switch mirrors in two ways: npm and nrm
![[Dataset][VOC] Eyewear dataset 6000 in VOC format](/img/66/37f76d9ce5d5f68d6ea0e18710fa04.png)
[Dataset][VOC] Eyewear dataset 6000 in VOC format

宝塔+FastAdmin 404 Not Found
随机推荐
At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died
MySQL高级-MVCC(超详细整理)
SphereEx苗立尧:云原生架构下的Database Mesh研发实践
A detailed introduction to the deployment and usage of the Nacos registry
MySQL (3)
Leetcode Weekly 304
HCIP day one
Node installation and environment configuration
项目开发规范
MySQL高级SQL语句
数据库概论之MySQL表的增删改查1
npm ---- install yarn
c语言指针运算
MySQL经典50道练习题及全网最详细解析
Toolbox App 1.25 New Features at a Glance | Version Update
Nodejs安装教程
返回文件名问题
能与观众实时互动的Claper
MySQL驱动jar包的下载--保姆教程
Connection reset by peer 问题解析