Submission #586168

# Submission time Handle Problem Language Result Execution time Memory
586168 2022-06-30T03:25:04 Z messiuuuuu Team Contest (JOI22_team) C++14
100 / 100
82 ms 4044 KB
#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 = 2e5 + 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();
}

Compilation message

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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 3780 KB Output is correct
12 Correct 23 ms 2640 KB Output is correct
13 Correct 25 ms 3248 KB Output is correct
14 Correct 33 ms 3796 KB Output is correct
15 Correct 29 ms 3796 KB Output is correct
16 Correct 26 ms 3804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 3780 KB Output is correct
12 Correct 23 ms 2640 KB Output is correct
13 Correct 25 ms 3248 KB Output is correct
14 Correct 33 ms 3796 KB Output is correct
15 Correct 29 ms 3796 KB Output is correct
16 Correct 26 ms 3804 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 41 ms 3840 KB Output is correct
23 Correct 35 ms 3668 KB Output is correct
24 Correct 29 ms 2900 KB Output is correct
25 Correct 41 ms 3844 KB Output is correct
26 Correct 30 ms 3748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 3780 KB Output is correct
12 Correct 23 ms 2640 KB Output is correct
13 Correct 25 ms 3248 KB Output is correct
14 Correct 33 ms 3796 KB Output is correct
15 Correct 29 ms 3796 KB Output is correct
16 Correct 26 ms 3804 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 41 ms 3840 KB Output is correct
23 Correct 35 ms 3668 KB Output is correct
24 Correct 29 ms 2900 KB Output is correct
25 Correct 41 ms 3844 KB Output is correct
26 Correct 30 ms 3748 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 47 ms 3580 KB Output is correct
35 Correct 45 ms 3516 KB Output is correct
36 Correct 52 ms 3852 KB Output is correct
37 Correct 51 ms 3824 KB Output is correct
38 Correct 36 ms 3652 KB Output is correct
39 Correct 20 ms 2400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 3780 KB Output is correct
12 Correct 23 ms 2640 KB Output is correct
13 Correct 25 ms 3248 KB Output is correct
14 Correct 33 ms 3796 KB Output is correct
15 Correct 29 ms 3796 KB Output is correct
16 Correct 26 ms 3804 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 41 ms 3840 KB Output is correct
23 Correct 35 ms 3668 KB Output is correct
24 Correct 29 ms 2900 KB Output is correct
25 Correct 41 ms 3844 KB Output is correct
26 Correct 30 ms 3748 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 47 ms 3580 KB Output is correct
35 Correct 45 ms 3516 KB Output is correct
36 Correct 52 ms 3852 KB Output is correct
37 Correct 51 ms 3824 KB Output is correct
38 Correct 36 ms 3652 KB Output is correct
39 Correct 20 ms 2400 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 61 ms 3856 KB Output is correct
45 Correct 61 ms 3856 KB Output is correct
46 Correct 64 ms 3744 KB Output is correct
47 Correct 62 ms 3788 KB Output is correct
48 Correct 45 ms 3848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 30 ms 3780 KB Output is correct
51 Correct 23 ms 2640 KB Output is correct
52 Correct 25 ms 3248 KB Output is correct
53 Correct 33 ms 3796 KB Output is correct
54 Correct 29 ms 3796 KB Output is correct
55 Correct 26 ms 3804 KB Output is correct
56 Correct 0 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 0 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 41 ms 3840 KB Output is correct
62 Correct 35 ms 3668 KB Output is correct
63 Correct 29 ms 2900 KB Output is correct
64 Correct 41 ms 3844 KB Output is correct
65 Correct 30 ms 3748 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 0 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 340 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 47 ms 3580 KB Output is correct
74 Correct 45 ms 3516 KB Output is correct
75 Correct 52 ms 3852 KB Output is correct
76 Correct 51 ms 3824 KB Output is correct
77 Correct 36 ms 3652 KB Output is correct
78 Correct 20 ms 2400 KB Output is correct
79 Correct 1 ms 340 KB Output is correct
80 Correct 2 ms 340 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 2 ms 340 KB Output is correct
83 Correct 61 ms 3856 KB Output is correct
84 Correct 61 ms 3856 KB Output is correct
85 Correct 64 ms 3744 KB Output is correct
86 Correct 62 ms 3788 KB Output is correct
87 Correct 45 ms 3848 KB Output is correct
88 Correct 78 ms 3724 KB Output is correct
89 Correct 79 ms 3872 KB Output is correct
90 Correct 77 ms 3916 KB Output is correct
91 Correct 82 ms 3928 KB Output is correct
92 Correct 73 ms 3936 KB Output is correct
93 Correct 82 ms 3884 KB Output is correct
94 Correct 75 ms 3924 KB Output is correct
95 Correct 56 ms 3868 KB Output is correct
96 Correct 78 ms 3928 KB Output is correct
97 Correct 44 ms 3916 KB Output is correct
98 Correct 40 ms 3916 KB Output is correct
99 Correct 67 ms 4044 KB Output is correct