标签:
Description
Input
Output
Sample Input
1 5 5 1 2 3 5 6 1 2 3 4 5
Sample Output
4 4 4 4
7
#include <iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,m,t; int f[200005]; int main() { scanf("%d",&t); for(;t>0;t--) { scanf("%d%d",&n,&m); memset(f,0,sizeof(f)); int x,mintime=2*100000+1; for(int i=1;i<=n;i++) {scanf("%d",&x); f[x]=-1;} for(int i=2*100000;i>0;i--) { if (f[i]!=-1) {f[i]=i; mintime=i;} else f[i]=mintime; } for(int i=1;i<=m;i++) { scanf("%d",&x); printf("%d\n",f[x]); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/stepping/p/5815047.html