Language: C++


bool lf(const T& p,const T& q)
{
    if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
    return p.a-p.c<q.a-q.c;
}

struct Tpq
{
    int id, d;
    bool operator <(const Tpq& e)const
    {
        return e.d<d;
    }
};

struct X
{
    long long x, y;
};
X s[maxn];

void Enter()
{
    cin>>x>>y>>z;
    n=x+y+z;
    for(int i=1;i<=n;i++)
        cin>>t[i].a>>t[i].b>>t[i].c;
    sort(t+1,t+n+1,lf);
}

void Solve()
{
    priority_queue<Tpq> l, r;
    long long sumx=0, sumy=0, sumz=0;
    for(int i=1;i<=x+y;i++)
    {
        l.push({i,t[i].b-t[i].a});
        sumy+=t[i].b;
        if(l.size()>y)
        {
            sumx+=t[l.top().id].a;
            sumy-=t[l.top().id].b;
            l.pop();
        }
        s[i]={sumx,sumy};
    }
    sumx=0;
    for(int i=n;i>n-x-z;i--)
    {
        r.push({i,t[i].c-t[i].a});
        sumz+=t[i].c;
        if(r.size()>z)
        {
            sumx+=t[r.top().id].a;
            sumz-=t[r.top().id].c;
            ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
            r.pop();
        }
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if(fopen(tasknames".INP","r"))
    {
    	freopen(tasknames".INP","r",stdin);
        freopen(tasknames".OUT","w",stdout);
    }
    Enter();
    Solve();
}


Compiler output:
a.cc:2:15: error: 'T' does not name a type
    2 | bool lf(const T& p,const T& q)
      |               ^
a.cc:2:26: error: 'T' does not name a type
    2 | bool lf(const T& p,const T& q)
      |                          ^
a.cc: In function 'bool lf(const int&, const int&)':
a.cc:4:10: error: request for member 'b' in 'p', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |          ^
a.cc:4:14: error: request for member 'c' in 'p', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |              ^
a.cc:4:19: error: request for member 'b' in 'q', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |                   ^
a.cc:4:23: error: request for member 'c' in 'q', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |                       ^
a.cc:4:34: error: request for member 'b' in 'p', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |                                  ^
a.cc:4:38: error: request for member 'c' in 'p', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |                                      ^
a.cc:4:42: error: request for member 'b' in 'q', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |                                          ^
a.cc:4:46: error: request for member 'c' in 'q', which is of non-class type 'const int'
    4 |     if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
      |                                              ^
a.cc:5:14: error: request for member 'a' in 'p', which is of non-class type 'const int'
    5 |     return p.a-p.c<q.a-q.c;
      |              ^
a.cc:5:18: error: request for member 'c' in 'p', which is of non-class type 'const int'
    5 |     return p.a-p.c<q.a-q.c;
      |                  ^
a.cc:5:22: error: request for member 'a' in 'q', which is of non-class type 'const int'
    5 |     return p.a-p.c<q.a-q.c;
      |                      ^
a.cc:5:26: error: request for member 'c' in 'q', which is of non-class type 'const int'
    5 |     return p.a-p.c<q.a-q.c;
      |                          ^
a.cc: At global scope:
a.cc:21:5: error: 'maxn' was not declared in this scope
   21 | X s[maxn];
      |     ^~~~
a.cc: In function 'void Enter()':
a.cc:25:5: error: 'cin' was not declared in this scope
   25 |     cin>>x>>y>>z;
      |     ^~~
a.cc:25:10: error: 'x' was not declared in this scope
   25 |     cin>>x>>y>>z;
      |          ^
a.cc:25:13: error: 'y' was not declared in this scope
   25 |     cin>>x>>y>>z;
      |             ^
a.cc:25:16: error: 'z' was not declared in this scope
   25 |     cin>>x>>y>>z;
      |                ^
a.cc:26:5: error: 'n' was not declared in this scope
   26 |     n=x+y+z;
      |     ^
a.cc:28:14: error: 't' was not declared in this scope
   28 |         cin>>t[i].a>>t[i].b>>t[i].c;
      |              ^
a.cc:29:10: error: 't' was not declared in this scope
   29 |     sort(t+1,t+n+1,lf);
      |          ^
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort(t+1,t+n+1,lf);
      |     ^~~~
      |     short
a.cc: In function 'void Solve()':
a.cc:34:5: error: 'priority_queue' was not declared in this scope
   34 |     priority_queue<Tpq> l, r;
      |     ^~~~~~~~~~~~~~
a.cc:34:23: error: expected primary-expression before '>' token
   34 |     priority_queue<Tpq> l, r;
      |                       ^
a.cc:34:25: error: 'l' was not declared in this scope; did you mean 'lf'?
   34 |     priority_queue<Tpq> l, r;
      |                         ^
      |                         lf
a.cc:34:28: error: 'r' was not declared in this scope
   34 |     priority_queue<Tpq> l, r;
      |                            ^
a.cc:36:20: error: 'x' was not declared in this scope
   36 |     for(int i=1;i<=x+y;i++)
      |                    ^
a.cc:36:22: error: 'y' was not declared in this scope
   36 |     for(int i=1;i<=x+y;i++)
      |                      ^
a.cc:38:19: error: 't' was not declared in this scope
   38 |         l.push({i,t[i].b-t[i].a});
      |                   ^
a.cc:46:9: error: 's' was not declared in this scope
   46 |         s[i]={sumx,sumy};
      |         ^
a.cc:49:15: error: 'n' was not declared in this scope
   49 |     for(int i=n;i>n-x-z;i--)
      |               ^
a.cc:49:21: error: 'x' was not declared in this scope
   49 |     for(int i=n;i>n-x-z;i--)
      |                     ^
a.cc:49:23: error: 'z' was not declared in this scope
   49 |     for(int i=n;i>n-x-z;i--)
      |                       ^
a.cc:51:19: error: 't' was not declared in this scope
   51 |         r.push({i,t[i].c-t[i].a});
      |                   ^
a.cc:57:13: error: 'ans' was not declared in this scope
   57 |             ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
      |             ^~~
a.cc:57:35: error: 's' was not declared in this scope
   57 |             ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
      |                                   ^
a.cc:57:17: error: 'max' was not declared in this scope
   57 |             ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
      |                 ^~~
a.cc:61:5: error: 'cout' was not declared in this scope
   61 |     cout<<ans;
      |     ^~~~
a.cc:61:11: error: 'ans' was not declared in this scope
   61 |     cout<<ans;
      |           ^~~
a.cc: In function 'int main()':
a.cc:66:5: error: 'ios_base' has not been declared
   66 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
a.cc:67:5: error: 'cin' was not declared in this scope
   67 |     cin.tie(nullptr);
      |     ^~~
a.cc:68:14: error: 'tasknames' was not declared in this scope
   68 |     if(fopen(tasknames".INP","r"))
      |              ^~~~~~~~~
a.cc:68:8: error: 'fopen' was not declared in this scope
   68 |     if(fopen(tasknames".INP","r"))
      |        ^~~~~
a.cc:1:1: note: 'fopen' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | 
a.cc:70:26: error: expected ')' before string constant
   70 |         freopen(tasknames".INP","r",stdin);
      |                ~         ^~~~~~
      |                          )
a.cc:70:37: error: 'stdin' was not declared in this scope
   70 |         freopen(tasknames".INP","r",stdin);
      |                                     ^~~~~
a.cc:70:37: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:70:9: error: 'freopen' was not declared in this scope
   70 |         freopen(tasknames".INP","r",stdin);
      |         ^~~~~~~
a.cc:71:26: error: expected ')' before string constant
   71 |         freopen(tasknames".OUT","w",stdout);
      |                ~         ^~~~~~
      |                          )
a.cc:71:37: error: 'stdout' was not declared in this scope
   71 |         freopen(tasknames".OUT","w",stdout);
      |                                     ^~~~~~
a.cc:71:37: note: 'stdout' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'