BestCoder Round #3

Task schedule http://acm.hdu.edu.cn/showproblem.php?pid=4907

 1 #include<cstdio>
 2 #include<cstring>
 3 #define mt(a,b) memset(a,b,sizeof(a))
 4 const int M=200010;
 5 int a[M];
 6 bool vis[M];
 7 int main(){
 8     int t,n,m;
 9     while(~scanf("%d",&t)){
10         while(t--){
11             scanf("%d%d",&n,&m);
12             mt(vis,0);
13             for(int i=1;i<=n;i++){
14                 scanf("%d",&a[i]);
15                 vis[a[i]]=true;
16             }
17             int x=1;
18             for(int i=1;i<=200000;i++){
19                 if(!vis[i]){
20                     for(int j=x;j<=i;j++){
21                         a[j]=i;
22                     }
23                     x=i+1;
24                 }
25             }
26             while(m--){
27                 scanf("%d",&x);
28                 printf("%d\n",a[x]);
29             }
30         }
31     }
32     return 0;
33 }
View Code

 

 

 

end

转载于:https://www.cnblogs.com/gaolzzxin/p/3890224.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值