Language: C++

#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

class select{
	public:
		int i;
		int j;
		int k;
		long sum;
};

bool operator>(class select S1,class select S2){
	return S1.sum>S2.sum;
}
bool operator<(class select S1,class select S2){
	return S1.sum<S2.sum;
}
bool operator==(class select S1,class select S2){
	return (S1.i==S2.i && S1.j==S2.j && S1.k==S2.k);
}




int main(){
	long X,Y,Z;
	long K;
	cin>>X>>Y>>Z>>K;
	vector<long>A,B,C;
	long tmp;
	for(int i=0;i<X;++i){
		cin>>tmp;
		A.push_back(tmp);
	}
	for(int i=0;i<Y;++i){
		cin>>tmp;
		B.push_back(tmp);
	}
	for(int i=0;i<Z;++i){
		cin>>tmp;
		C.push_back(tmp);
	}
	sort(A.begin(),A.end(),greater<long>());
	sort(B.begin(),B.end(),greater<long>());
	sort(C.begin(),C.end(),greater<long>());
	select status;
	status.i=0;
	status.j=0;
	status.k=0;
	status.sum=A[status.i]+B[status.j]+C[status.k];
	priority_queue<select>q;
	q.push(status);
	vector<select>statusarr;
	vector<long>ans;
	while(true){
		status=q.top();
		//cout<<status.i<<" "<<status.j<<" "<<status.k<<endl;
		q.pop();
		int tmp=0;
		for(int i=0;i<statusarr.size();++i){
			if(statusarr[i]==status)tmp=1;
		}
		if(tmp==1)continue;
		statusarr.push_back(status);
		ans.push_back(status.sum);
		if(ans.size()==K)break;
		if(status.i<X-1){
			status.i++;
			status.sum+=-A[status.i-1]+A[status.i];
			q.push(status);
			status.i--;
			status.sum+=-A[status.i+1]+A[status.i];
		}
		if(status.j<Y-1){
			status.j++;
			status.sum+=-B[status.j-1]+B[status.j];
			q.push(status);
			status.j--;
			status.sum+=-B[status.j+1]+B[status.j];
		}
		if(status.k<Z-1){
			status.k++;
			status.sum+=-C[status.k-1]+C[status.k];
			q.push(status);
			status.k--;
			status.sum+=-C[status.k+1]+C[status.k];
		}
	}
	for(int i=0;i<ans.size();++i){
		cout<<ans[i]<<endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:15: error: expected ';' before 'status'
   49 |         select status;
      |               ^~~~~~~
      |               ;
a.cc:50:9: error: 'status' was not declared in this scope; did you mean 'static'?
   50 |         status.i=0;
      |         ^~~~~~
      |         static
a.cc:54:30: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue'
   54 |         priority_queue<select>q;
      |                              ^
a.cc:54:30: note:   expected a type, got 'select'
a.cc:54:30: error: template argument 2 is invalid
a.cc:54:30: error: template argument 3 is invalid
a.cc:55:11: error: request for member 'push' in 'q', which is of non-class type 'int'
   55 |         q.push(status);
      |           ^~~~
a.cc:56:22: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   56 |         vector<select>statusarr;
      |                      ^
a.cc:56:22: note:   expected a type, got 'select'
a.cc:56:22: error: template argument 2 is invalid
a.cc:59:26: error: request for member 'top' in 'q', which is of non-class type 'int'
   59 |                 status=q.top();
      |                          ^~~
a.cc:61:19: error: request for member 'pop' in 'q', which is of non-class type 'int'
   61 |                 q.pop();
      |                   ^~~
a.cc:63:41: error: request for member 'size' in 'statusarr', which is of non-class type 'int'
   63 |                 for(int i=0;i<statusarr.size();++i){
      |                                         ^~~~
a.cc:64:37: error: invalid types 'int[int]' for array subscript
   64 |                         if(statusarr[i]==status)tmp=1;
      |                                     ^
a.cc:67:27: error: request for member 'push_back' in 'statusarr', which is of non-class type 'int'
   67 |                 statusarr.push_back(status);
      |                           ^~~~~~~~~
a.cc:73:27: error: request for member 'push' in 'q', which is of non-class type 'int'
   73 |                         q.push(status);
      |                           ^~~~
a.cc:80:27: error: request for member 'push' in 'q', which is of non-class type 'int'
   80 |                         q.push(status);
      |                           ^~~~
a.cc:87:27: error: request for member 'push' in 'q', which is of non-class type 'int'
   87 |                         q.push(status);
      |                           ^~~~