Language: C++

#include<bits/stdc++.h>
#define int long long
#define f(n) for(int i=0;i<n;i++)
using namespace std;
class P{
  int s,i,j,k;
  P(int g,int a,int b,int c){
    s=g;
    i=a;
    j=b;
    k=c;
  };
  bool operator< (const P &p1, const P &p2){
    return p1.s<p2.s;
  };
};
signed main(){
  int x,y,z,K;
  cin>>x>>y>>z>>K;
  int a[x],b[y],c[z];
  int s,i,j,k;
  f(x)cin>>a[i];
  f(y)cin>>b[i];
  f(z)cin>>c[i];
  sort(a,a+x);
  sort(b,b+y);
  sort(c,c+z);
  
  int a1[x+1]={0},b1[y+1]={0},c1[z+1]={0};
  f(x)a1[i+1]=a[i];
  f(y)b1[i+1]=b[i];
  f(z)c1[i+1]=c[i];
  
  priority_queue<P> q;
  q.push(a[1]+b[1]+c[1],1,1,1);
  int cnt=0;
  while(cnt<=K){
    s=q.top().s;
    i=q.top().i;
    j=q.top().j;
    k=q.top().k;
    cout<<s<<endl;
    q.pop();
    q.push(P(a[i+1]+b[j]+c[k],i+1,j,k));
    q.push(P(a[i]+b[j+1]+c[k],i,j+1,k));
    q.push(P(a[i]+b[j]+c[k+1],i,j,k+1));
    cnt++;
  }
  return 0;
}

Compiler output:
a.cc:13:8: error: 'bool P::operator<(const P&, const P&)' must have exactly one argument
   13 |   bool operator< (const P &p1, const P &p2){
      |        ^~~~~~~~
a.cc: In function 'int main()':
a.cc:35:9: error: no matching function for call to 'std::priority_queue<P>::push(long long int, int, int, int)'
   35 |   q.push(a[1]+b[1]+c[1],1,1,1);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = P; _Sequence = std::vector<P, std::allocator<P> >; _Compare = std::less<P>; value_type = P]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:7: note:   candidate expects 1 argument, 4 provided
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = P; _Sequence = std::vector<P, std::allocator<P> >; _Compare = std::less<P>; value_type = P]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note:   candidate expects 1 argument, 4 provided
a.cc:38:15: error: 'long long int P::s' is private within this context
   38 |     s=q.top().s;
      |               ^
a.cc:6:7: note: declared private here
    6 |   int s,i,j,k;
      |       ^
a.cc:39:15: error: 'long long int P::i' is private within this context
   39 |     i=q.top().i;
      |               ^
a.cc:6:9: note: declared private here
    6 |   int s,i,j,k;
      |         ^
a.cc:40:15: error: 'long long int P::j' is private within this context
   40 |     j=q.top().j;
      |               ^
a.cc:6:11: note: declared private here
    6 |   int s,i,j,k;
      |           ^
a.cc:41:15: error: 'long long int P::k' is private within this context
   41 |     k=q.top().k;
      |               ^
a.cc:6:13: note: declared private here
    6 |   int s,i,j,k;
      |             ^
a.cc:44:38: error: 'P::P(long long int, long long int, long long int, long long int)' is private within this context
   44 |     q.push(P(a[i+1]+b[j]+c[k],i+1,j,k));
      |                                      ^
a.cc:7:3: note: declared private here
    7 |   P(int g,int a,int b,int c){
      |   ^
a.cc:45:38: error: 'P::P(long long int, long long int, long long int, long long int)' is private within this context
   45 |     q.push(P(a[i]+b[j+1]+c[k],i,j+1,k));
      |                                      ^
a.cc:7:3: note: declared private here
    7 |   P(int g,int a,int b,int c){
      |   ^
a.cc:46:38: error: 'P::P(long long int, long long int, long long int, long long int)' is private within this context
   46 |     q.push(P(a[i]+b[j]+c[k+1],i,j,k+1));
      |                                      ^
a.cc:7:3: note: declared private here
    7 |   P(int g,int a,int b,int c){
      |   ^
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = P]':
/usr/include/c++/14/bits/predefined_ops.h:196:23:   required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<P*, std::vector<P, std::allocator<P> > >; _Value = P; _Compare = std::less<P>]'
  196 |         { return bool(_M_comp(*__it, __val)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<P*, vector<P, allocator<P> > >; _Distance = long int; _Tp = P; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<P> >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<P*, vector<P, allocator<P> > >; _Compare = less<P>]'
  216 |       std::__push_heap(__first, _DistanceType((__last - __first) - 1),
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |                        _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = P; _Sequence = std::vector<P, std::allocator<P> >; _Compare = std::less<P>; value_type = P]'
  747 |         std::push_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:44:11:   required from here
   44 |     q.push(P(a[i+1]+b[j]+c[k],i+1,j,k));
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const P' and 'const P')
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const P' is not derived from 'const std::pair<_T1, _T2>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const P' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const P' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const P' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const P' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~