fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MaxN=5e5;
  5. int N,x,Q,p;
  6. int A[MaxN];
  7.  
  8. int main() {
  9. cin>>N>>Q;
  10. for(int n=0 ;n<N;n++)
  11. cin>>A[n];
  12. sort(A,A+N);
  13. for(int q=0;q<Q;q++){
  14. cin>>x;
  15. p=upper_bound(A,A+N,x)-A;
  16. if(p%2==0)
  17. cout<<0<<endl;
  18. else if(p%2==1)
  19. cout<<1<<endl;
  20. }
  21. }
Success #stdin #stdout 0.01s 5280KB
stdin
5 3
3 1 3 2 8
3 6 9
stdout
0
0
1