bool f1,f2;
int n,q,k,ans=-1;
vector<int>A;

これ業務じゃダメなんですか?