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 }
end