Submission #880242

#TimeUsernameProblemLanguageResultExecution timeMemory
880242RegulusTeam Contest (JOI22_team)C++17
9 / 100
126 ms8932 KiB
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
 
const int N = 2e5+5;
const int Mxm = 10;
ll x[N], y[N], z[N], c[N], cc[Mxm][Mxm][Mxm];
vector<int> v;

inline bool cmp_x(int a, int b) { return x[a] > x[b]; }
inline bool cmp_y(int a, int b) { return y[a] > y[b]; }
inline bool cmp_z(int a, int b) { return z[a] > z[b]; }
 
int main(void)
{ IO
    ll n, i, j, k, tmp, mx=-1, m=0;

    cin >> n;
    for (i=1; i <= n; ++i)
    {
        cin >> x[i] >> y[i] >> z[i];
        cc[x[i]][y[i]][z[i]] = 1;
    }

    for (i=1; i <= 5; ++i)
    {
        for (j=1; j <= 5; ++j)
        {
            for (k=1; k <= 5; ++k)
            {
                if (cc[i][j][k])
                {
                    ++m;
                    x[m] = i, y[m] = j, z[m] = k;
                }
            }
        }
    }
    
    for (i=1; i <= m; ++i)
    {
        for (j=1; j <= m; ++j)
        {
            if (i == j) continue;
            for (k=1; k <= m; ++k)
            {
                if (i == k || j == k) continue;
                v.clear();
                v.pb(i), v.pb(j), v.pb(k), c[i] = c[j] = c[k] = 0;
                tmp = 0;

                sort(all(v), cmp_x);
                c[v[0]] = (x[v[0]] != x[v[1]]), tmp += x[v[0]];
                sort(all(v), cmp_y);
                c[v[0]] = (y[v[0]] != y[v[1]]), tmp += y[v[0]];
                sort(all(v), cmp_z);
                c[v[0]] = (z[v[0]] != z[v[1]]), tmp += z[v[0]];

                if (c[i] + c[j] + c[k] == 3) mx = max(mx, tmp);
            }
        }
    }

    cout << mx << '\n';

 
    return 0;
}

/*
5
3 1 4
2 3 1
1 5 5
4 4 2
5 2 3

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...