set中重载运算符()进行自定义排序

using namespace std;
int m, k, x;
struct cmp{
    bool operator()(const int &a, const int &b) const{
        if(abs(a - b) <= k)    return 0;
        return a < b;
    }
};
int main(){
    cin >> m >> k;
    char s[10];
    set <int, cmp> st;
    for(int i = 1; i <= m; i ++){
        scanf("%s %d", s, &x);
//         cout << s << endl;
        if(s[0] == 'a')    st.insert(x);
        else if(s[0] == 'd')    st.erase(x);
        else{
            if(st.find(x) != st.end())    printf("Yes\n");
            else    printf("No\n");
        }
    }
}