Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int DIM=1010;
long A[DIM];
long B[DIM];
long C[DIM];
long ANS[DIM];

     
     
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    long p;
    int i,j,k;
    int X,Y,Z,K;
    long min=0; 
    priority_queue<long> pq;
    cin >> X >> Y >> Z >> K; 
    // cout << X << " " << Y << " " << Z << " " << K << "\n"; 
    for(i=1; i<= X; i++){ cin >> p; A[i]=p;}
    for(j=1; j<= Y; j++){ cin >> p; B[j]=p; }
    for(k=1; k<= Z; k++){ cin >> p; C[k]=p; }
    
    sort(A+1,A + 1+ X, greater<>());
    sort(B+1,B + 1+ Y, greater<>());
    sort(C+1,C + 1+ Z, greater<>());

    /* 
    for(i=1; i<= X; i++){ cout << A[i] << " "; }
    cout << "\n";
    for(j=1; j<= Y; j++){ cout << B[j] << " "; }
    cout << "\n";
    for(k=1; k<= Z; k++){ cout << C[k] << " "; }
    cout << "\n";
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int DIM=1010;
long A[DIM];
long B[DIM];
long C[DIM];
long ANS[DIM];

     
     
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    long p;
    int i,j,k;
    int X,Y,Z,K;
    long min=0; 
    priority_queue<long> pq;
    cin >> X >> Y >> Z >> K; 
    // cout << X << " " << Y << " " << Z << " " << K << "\n"; 
    for(i=1; i<= X; i++){ cin >> p; A[i]=p;}
    for(j=1; j<= Y; j++){ cin >> p; B[j]=p; }
    for(k=1; k<= Z; k++){ cin >> p; C[k]=p; }
    
    sort(A+1,A + 1+ X, greater<>());
    sort(B+1,B + 1+ Y, greater<>());
    sort(C+1,C + 1+ Z, greater<>());

    /* 
    for(i=1; i<= X; i++){ cout << A[i] << " "; }
    cout << "\n";
    for(j=1; j<= Y; j++){ cout << B[j] << " "; }
    cout << "\n";
    for(k=1; k<= Z; k++){ cout << C[k] << " "; }
    cout << "\n";
    */
    long maxBC = B[1] + C[1];
    long maxC = C[1];


    for(i=1; i<= X; i++){
        // cout << "check A: " << A[i] << "\n";
        if (A[i] + maxBC < min){break;}
        for(j=1; j<= Y; j++){
            if (A[i] + B[j] + maxC < min){break;}
            for(k=1; k<= Z; k++){
                if (A[i] + B[j] + C[k] < min){break;}
                // cout << "size " << pq.size() << " push " << A[i] + B[j] + C[k] << "\n";
                pq.push( -(A[i] + B[j] + C[k]) );
                // cout << "top " << -pq.top() << "\n";
                if (pq.size()>K){
                    // cout << "drop " << - pq.top();
                    pq.pop();
                    min = - pq.top();
                    // cout << " min " << min << "\n";
                }
            }
        }
    }
    //exit(0);
    for(i=1;i<=K;i++){
         ANS[K+1-i]= -pq.top(); 
         pq.pop(); 
    }
    for(i=1;i<=K;i++){
        cout << ANS[i] <<  "\n"; 
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   48 | int main() {
      |         ^~
a.cc:48:9: note: remove parentheses to default-initialize a variable
   48 | int main() {
      |         ^~
      |         --
a.cc:48:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:48:12: error: a function-definition is not allowed here before '{' token
   48 | int main() {
      |            ^
a.cc:104:2: error: expected '}' at end of input
  104 | }
      |  ^
a.cc:12:12: note: to match this '{'
   12 | int main() {
      |            ^