Language: C++

#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	bool operator<(const struct Info &arg) const{
		return score < arg.score;
	};
	int id,score;
};

struct Data{
	Data(int arg_diff,int arg_index,int arg_leader_number){
		diff = arg_diff;
		index = arg_index;
		leader_number = arg_leader_number;
	}
	bool operator<(const struct Data &arg) const{
		return diff > arg.diff;
	};
	int diff,index,leader_number;
};

int main(){

	int N,Q;
	scanf("%d %d",&N,&Q);

	Info* info = (Info*)malloc(sizeof(Info)*(N+1));

	info[0].score = -1;
	for(int i = 1; i <= N; i++){
		scanf("%d",&info[i].score);
		info[i].id = i;
	}

	sort(info,info+(N+1));

	int* loc = new int[N+1]; //??°?????????????????????????¨??????????????????????

	for(int i = 1; i <= N; i++){
		loc[info[i].id] = i;
	}

	char order[10];
	int value,current_number,need_number;
	int left_index[100],self_score[100],max_loc;

	bool* check = new bool[N+1];

	vector<int> V;
	priority_queue<Data> PQ;

	Data data;

	for(int loop = 0; loop < Q; loop++){
		scanf("%s %d",order,&value);

		switch(order[0]){
		case 'A':
			V.push_back(value);
			break;
		case 'R':
			for(int i = 0; i < V.size(); i++){
				if(V[i] == value){
					V.erase(V.begin()+i);
					break;
				}
			}
			break;
		case 'C':
			need_number = N - value;

			for(int i = 1; i <= N; i++){
				check[i] = false;
			}

			current_number = 0;
			max_loc = 0;

			for(int i = 0; i < V.size(); i++){
				check[loc[V[i]]] = true;
				max_loc = max(max_loc,loc[V[i]]);
				self_score[i] = info[loc[V[i]]].score;
				current_number++;

				left_index[i] = loc[V[i]];

				//?????????????????????????????¨???????????????????????????
				for(int k = loc[V[i]]-1; k >= 1 && info[k].score == self_score[i] && check[k] == false;k--){
					current_number++;
					left_index[i] = k;
					check[k] = true;
				}

				for(int k = loc[V[i]]+1; k <= N && info[k].score == self_score[i] && check[k] == false;k++){
					current_number++;
					max_loc = max(max_loc,k);
					check[k]=true;
				}
			}

			if(current_number >= need_number){
				printf("0\n");
				continue;
			}else if(max_loc < need_number){
				printf("NA\n");
				continue;
			}

			while(!PQ.empty())PQ.pop();

			for(int i = 0; i < V.size(); i++){
				if(left_index[i] >= 2){
					PQ.push(Data(self_score[i]-info[left_index[i]-1].score,left_index[i]-1,i));
				}
			}

			int ans = 0;

			while(current_number < need_number){
				ans = max(ans,PQ.top().diff);

				data = PQ.top();
				PQ.pop();

				for(int k = data.index; k >= 1 && check[k] == false && self_score[data.leader_number]-info[k].score == data.diff;k--){
					current_number++;
					left_index[data.leader_number] = k;
					check[k] = true;
				}

				if(left_index[data.leader_number] >= 2 && check[left_index[data.leader_number]-1] == false){
					PQ.push(Data(self_score[data.leader_number]-info[left_index[data.leader_number]-1].score,left_index[data.leader_number]-1,data.leader_number));
				}
			}

			printf("%d\n",ans);

			break;
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:14: error: no matching function for call to 'Data::Data()'
   68 |         Data data;
      |              ^~~~
a.cc:27:9: note: candidate: 'Data::Data(int, int, int)'
   27 |         Data(int arg_diff,int arg_index,int arg_leader_number){
      |         ^~~~
a.cc:27:9: note:   candidate expects 3 arguments, 0 provided
a.cc:26:8: note: candidate: 'constexpr Data::Data(const Data&)'
   26 | struct Data{
      |        ^~~~
a.cc:26:8: note:   candidate expects 1 argument, 0 provided
a.cc:26:8: note: candidate: 'constexpr Data::Data(Data&&)'
a.cc:26:8: note:   candidate expects 1 argument, 0 provided