Skip to content

Instantly share code, notes, and snippets.

@anik889
Created November 25, 2021 08:56
Show Gist options
  • Save anik889/fd3fc0de1b1854ae7462863717c318af to your computer and use it in GitHub Desktop.
Save anik889/fd3fc0de1b1854ae7462863717c318af to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<math.h>
int main() {
int n,m;
scanf("%d %d",&n,&m);
int a,c1=0,c2=0;
for(int i=1; i<=n; i++){
scanf("%d",&a);
if(a==1) c1++;
else c2++;
}
for(int i=1; i<=m; i++) {
int l,r,c=0;
scanf("%d %d",&l,&r);
int s=fabs(r-l)+1;
if(s%2==0 && c1>=(s/2) && c2>=(s/2))
printf("1\n");
else
printf("0\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment