제출 #586167

#제출 시각아이디문제언어결과실행 시간메모리
586167messiuuuuuTeam Contest (JOI22_team)C++14
37 / 100
16 ms5172 KiB
#include<bits/stdc++.h>
#define task "A"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 5;

int x[MAXN], y[MAXN], z[MAXN], a[MAXN], b[MAXN], c[MAXN];
int n;

void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
        a[i] = b[i] = c[i] = i;
    }
}

void Solve()
{
    sort(a + 1, a + n + 1, [](int i, int j)
         {
             return x[i] < x[j];
         });
    sort(b + 1, b + n + 1, [](int i, int j)
         {
             return y[i] < y[j];
         });
    sort(c + 1, c + n + 1, [](int i, int j)
         {
             return z[i] < z[j];
         });
    int i = n, j = n, t = n;
    while (i >= 1 && j >= 1 && t >= 1)
    {
        //cout << i << ' ' << j << ' ' << t << '\n';
        if (x[a[i]] <= x[b[j]])
        {
            j--;
            continue;
        }
        if (x[a[i]] <= x[c[t]])
        {
            t--;
            continue;
        }
        if (y[b[j]] <= y[a[i]])
        {
            i--;
            continue;
        }
        if (y[b[j]] <= y[c[t]])
        {
            t--;
            continue;
        }
        if (z[c[t]] <= z[a[i]])
        {
            i--;
            continue;
        }
        if (z[c[t]] <= z[b[j]])
        {
            j--;
            continue;
        }
        cout << x[a[i]] + y[b[j]] + z[c[t]];
        return;
    }
    cout << -1;
}

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

컴파일 시 표준 에러 (stderr) 메시지

team.cpp: In function 'int main()':
team.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...