当前位置:网站首页>【暑期每日一题】洛谷 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
5
AC 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;
}
边栏推荐
- Difference between npm and yarn
- Dataset:机器学习中常用数据集下载链接集合之详细攻略
- MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
- Wuhan 2022 organizing of the high-performance computing added new ecological development of high-performance computing
- (部分不懂,笔记整理未完成)【图论】差分约束
- Summer Summary (3)
- July 18-July 31, 2022 (Ue4 video tutorials and documentation, 20 hours. Total 1412 hours, 8588 hours left)
- love
- Clapper that can interact with the audience in real time
- node安装及环境配置
猜你喜欢
Nacos installation detailed process
nodejs的安装和全局配置(超详细哦)
MySQL高级SQL语句(二)
[Dataset][VOC] Eyewear dataset 6000 in VOC format
See the picture to understand | How to choose sales indicators to measure the health of business growth
PMP新考纲考试内容介绍
Wuhan 2022 organizing of the high-performance computing added new ecological development of high-performance computing
Day 4 of HCIP
8/1 思维+扩展欧几里得+树上dp
BGP+MPLS Comprehensive Experiment
随机推荐
Clapper that can interact with the audience in real time
武汉高性能计算大会2022举办,高性能计算生态发展再添新动力
Project development specification
Summer Summary (3)
Mining game (C language)
享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世
HCIP 第三天实验
View source and switch mirrors in two ways: npm and nrm
MySQL classic 50 practice questions and the most detailed analysis of the whole network
SphereEx苗立尧:云原生架构下的Database Mesh研发实践
Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
MySQL union query (multi-table query)
Understand C operators in one article
MySQL Index Common Interview Questions (2022 Edition)
关于ue4.27像素流送打包后的本地服务器问题
Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains
BGP+MPLS Comprehensive Experiment
Toolbox App 1.25 新功能一览 | 版本更新
看图就懂|衡量业务增长健康的销售指标如何选择
Node installation and environment variable configuration