【枚举标记】HDU4907Task schedule【BestCoder Round #3】

xiaoxiao2021-02-28  117

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4907

#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=200005; int tmp[N]; int a[N],ans[N]; int n,m; void Input() { memset(tmp,0,sizeof(tmp)); cin>>n>>m; int k,Min=N; for(int i=0;i<n;i++){ cin>>k; tmp[k]=1; } for(int i=N;i>0;i--){ if(tmp[i]==0) Min=i; ans[i]=Min; } for(int j=0;j<m;j++){ cin>>k; cout<<ans[k]<<endl; } } int main() { int t; cin.sync_with_stdio(false); cin>>t; while(t--){ Input(); } return 0; }

转载请注明原文地址: https://www.6miu.com/read-67632.html

最新回复(0)