码迷,mamicode.com
首页 > 其他好文 > 详细

BestCoder Round #3

时间:2014-08-04 17:01:07      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   art   

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

bubuko.com,布布扣
 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

BestCoder Round #3,布布扣,bubuko.com

BestCoder Round #3

标签:style   blog   http   color   os   io   for   art   

原文地址:http://www.cnblogs.com/gaolzzxin/p/3890224.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!