Language: C++

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

class select{
	public:
		int i;
		int j;
		int k;
		long sum;
	select(int i,int j,int k,long sum){
		this->i=i;
		this->j=j;
		this->k=k;
		this->sum=sum;
	}
};

bool operator< (const select &s1,const select &s2){
	return s1.sum<s2.sum;
};

bool operator> (const select &s1,const select &s2){
	return s1.sum>s2.sum;
};

bool operator== (const select &s1,const 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(0,0,0,A[0]+B[0]+C[0]);
	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:21:23: error: 'select' does not name a type
   21 | bool operator< (const select &s1,const select &s2){
      |                       ^~~~~~
a.cc:21:40: error: 'select' does not name a type
   21 | bool operator< (const select &s1,const select &s2){
      |                                        ^~~~~~
a.cc:21:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
   21 | bool operator< (const select &s1,const select &s2){
      |      ^~~~~~~~
a.cc:25:23: error: 'select' does not name a type
   25 | bool operator> (const select &s1,const select &s2){
      |                       ^~~~~~
a.cc:25:40: error: 'select' does not name a type
   25 | bool operator> (const select &s1,const select &s2){
      |                                        ^~~~~~
a.cc:25:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
   25 | bool operator> (const select &s1,const select &s2){
      |      ^~~~~~~~
a.cc:29:24: error: 'select' does not name a type
   29 | bool operator== (const select &s1,const select &s2){
      |                        ^~~~~~
a.cc:29:41: error: 'select' does not name a type
   29 | bool operator== (const select &s1,const select &s2){
      |                                         ^~~~~~
a.cc:29:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
   29 | bool operator== (const select &s1,const select &s2){
      |      ^~~~~~~~
a.cc: In function 'int main()':
a.cc:54:15: error: expected ';' before 'status'
   54 |         select status(0,0,0,A[0]+B[0]+C[0]);
      |               ^~~~~~~
      |               ;
a.cc:55:30: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue'
   55 |         priority_queue<select>q;
      |                              ^
a.cc:55:30: note:   expected a type, got 'select'
a.cc:55:30: error: template argument 2 is invalid
a.cc:55:30: error: template argument 3 is invalid
a.cc:56:11: error: request for member 'push' in 'q', which is of non-class type 'int'
   56 |         q.push(status);
      |           ^~~~
a.cc:56:16: error: 'status' was not declared in this scope; did you mean 'static'?
   56 |         q.push(status);
      |                ^~~~~~
      |                static
a.cc:57:22: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   57 |         vector<select>statusarr;
      |                      ^
a.cc:57:22: note:   expected a type, got 'select'
a.cc:57:22: error: template argument 2 is invalid
a.cc:60:26: error: request for member 'top' in 'q', which is of non-class type 'int'
   60 |                 status=q.top();
      |                          ^~~
a.cc:62:19: error: request for member 'pop' in 'q', which is of non-class type 'int'
   62 |                 q.pop();
      |                   ^~~
a.cc:64:41: error: request for member 'size' in 'statusarr', which is of non-class type 'int'
   64 |                 for(int i=0;i<statusarr.size();++i){
      |                                         ^~~~
a.cc:65:37: error: invalid types 'int[int]' for array subscript
   65 |                         if(statusarr[i]==status)tmp=1;
      |                                     ^
a.cc:68:27: error: request for member 'push_back' in 'statusarr', which is of non-class type 'int'
   68 |                 statusarr.push_back(status);
      |                           ^~~~~~~~~
a.cc:74:27: error: request for member 'push' in 'q', which is of non-class type 'int'
   74 |                         q.push(status);
      |                           ^~~~
a.cc:81:27: error: request for member 'push' in 'q', which is of non-class type 'int'
   81 |                         q.push(status);
      |                           ^~~~
a.cc:88:27: error: request for member 'push' in 'q', which is of non-class type 'int'
   88 |                         q.push(status);
      |                           ^~~~