fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MaxN=5e5;
  5. int num[MaxN];
  6. int N,Q,x;
  7.  
  8. int main(){
  9. while(cin>>N>>Q){
  10. for(int n=0;n<N;n++)
  11. cin>>num[n];
  12. sort(num,num+N);
  13. for(int q=0;q<Q;q++){
  14. cin>>x;
  15. if(x<num[0]){
  16. cout<<0<<"\n";
  17. continue;
  18. }
  19.  
  20. int ans=upper_bound(num,num+N,x)-num;
  21. //第一個大於x的位置
  22. if(ans%2==0)
  23. cout<<0<<"\n";
  24. else
  25. cout<<1<<"\n";
  26.  
  27. }
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5268KB
stdin
5 3
3 1 3 2 8
3 6 9
stdout
0
0
1