#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define vi vector<int>
#define ve vector
#define ll long long
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define onbit __builtin_popcount
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e18
#define eps 1e-7
#define eps1 1e-2
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll MOD = 1e9+7;
const int nax = 105;
const int MAX_VAL = 1e6+1;
double PI=3.14159265359;
int arx[8]={1,0,0,-1,-1,-1, 1, 1};
int ary[8]={0,1,-1, 0, 1,-1,-1, 1};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
optimise;
//setIO("dec");
int n;
cin>>n;
int x[n],y[n],z[n];
set<ii> xr,yr,zr;
for (int i = 0; i < n; ++i)
{
cin>>x[i]>>y[i]>>z[i];
xr.insert({x[i],i});
yr.insert({y[i],i});
zr.insert({z[i],i});
}
int res=-1;
while(!xr.empty()&&!yr.empty()&&!zr.empty()){
int px=xr.rbegin()->se;
int py=yr.rbegin()->se;
int pz=zr.rbegin()->se;
//cout <<px<<" "<<py<<" "<<pz<<endl;
if(z[px]>=z[pz]||y[px]>=y[py]){
xr.erase({x[px],px});
yr.erase({y[px],px});
zr.erase({z[px],px});
continue;
}
if(z[py]>=z[pz]||x[py]>=x[px]){
xr.erase({x[py],py});
yr.erase({y[py],py});
zr.erase({z[py],py});
continue;
}if(x[pz]>=x[px]||y[pz]>=y[py]){
xr.erase({x[pz],pz});
yr.erase({y[pz],pz});
zr.erase({z[pz],pz});
continue;
}
res=x[px]+y[py]+z[pz];
break;
}
cout <<res<<endl;
}
Compilation message
team.cpp: In function 'void setIO(std::string)':
team.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | freopen((s + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | freopen((s + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
460 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
460 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
4 ms |
1116 KB |
Output is correct |
27 |
Correct |
3 ms |
1076 KB |
Output is correct |
28 |
Correct |
4 ms |
1116 KB |
Output is correct |
29 |
Correct |
4 ms |
1112 KB |
Output is correct |
30 |
Correct |
3 ms |
860 KB |
Output is correct |
31 |
Correct |
3 ms |
860 KB |
Output is correct |
32 |
Correct |
4 ms |
860 KB |
Output is correct |
33 |
Correct |
3 ms |
1116 KB |
Output is correct |
34 |
Correct |
4 ms |
1116 KB |
Output is correct |
35 |
Correct |
1 ms |
604 KB |
Output is correct |
36 |
Correct |
1 ms |
604 KB |
Output is correct |
37 |
Correct |
2 ms |
1036 KB |
Output is correct |
38 |
Correct |
3 ms |
1116 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
122 ms |
24104 KB |
Output is correct |
12 |
Correct |
94 ms |
16256 KB |
Output is correct |
13 |
Correct |
88 ms |
20048 KB |
Output is correct |
14 |
Correct |
158 ms |
24144 KB |
Output is correct |
15 |
Correct |
123 ms |
24144 KB |
Output is correct |
16 |
Correct |
106 ms |
24120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
122 ms |
24104 KB |
Output is correct |
12 |
Correct |
94 ms |
16256 KB |
Output is correct |
13 |
Correct |
88 ms |
20048 KB |
Output is correct |
14 |
Correct |
158 ms |
24144 KB |
Output is correct |
15 |
Correct |
123 ms |
24144 KB |
Output is correct |
16 |
Correct |
106 ms |
24120 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
147 ms |
24404 KB |
Output is correct |
23 |
Correct |
148 ms |
23632 KB |
Output is correct |
24 |
Correct |
124 ms |
17768 KB |
Output is correct |
25 |
Correct |
204 ms |
24400 KB |
Output is correct |
26 |
Correct |
125 ms |
24144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
122 ms |
24104 KB |
Output is correct |
12 |
Correct |
94 ms |
16256 KB |
Output is correct |
13 |
Correct |
88 ms |
20048 KB |
Output is correct |
14 |
Correct |
158 ms |
24144 KB |
Output is correct |
15 |
Correct |
123 ms |
24144 KB |
Output is correct |
16 |
Correct |
106 ms |
24120 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
147 ms |
24404 KB |
Output is correct |
23 |
Correct |
148 ms |
23632 KB |
Output is correct |
24 |
Correct |
124 ms |
17768 KB |
Output is correct |
25 |
Correct |
204 ms |
24400 KB |
Output is correct |
26 |
Correct |
125 ms |
24144 KB |
Output is correct |
27 |
Correct |
1 ms |
456 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
4 ms |
940 KB |
Output is correct |
32 |
Correct |
1 ms |
604 KB |
Output is correct |
33 |
Correct |
2 ms |
604 KB |
Output is correct |
34 |
Correct |
231 ms |
23712 KB |
Output is correct |
35 |
Correct |
217 ms |
22608 KB |
Output is correct |
36 |
Correct |
239 ms |
24844 KB |
Output is correct |
37 |
Correct |
277 ms |
24660 KB |
Output is correct |
38 |
Correct |
177 ms |
24148 KB |
Output is correct |
39 |
Correct |
75 ms |
14932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
122 ms |
24104 KB |
Output is correct |
12 |
Correct |
94 ms |
16256 KB |
Output is correct |
13 |
Correct |
88 ms |
20048 KB |
Output is correct |
14 |
Correct |
158 ms |
24144 KB |
Output is correct |
15 |
Correct |
123 ms |
24144 KB |
Output is correct |
16 |
Correct |
106 ms |
24120 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
147 ms |
24404 KB |
Output is correct |
23 |
Correct |
148 ms |
23632 KB |
Output is correct |
24 |
Correct |
124 ms |
17768 KB |
Output is correct |
25 |
Correct |
204 ms |
24400 KB |
Output is correct |
26 |
Correct |
125 ms |
24144 KB |
Output is correct |
27 |
Correct |
1 ms |
456 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
4 ms |
940 KB |
Output is correct |
32 |
Correct |
1 ms |
604 KB |
Output is correct |
33 |
Correct |
2 ms |
604 KB |
Output is correct |
34 |
Correct |
231 ms |
23712 KB |
Output is correct |
35 |
Correct |
217 ms |
22608 KB |
Output is correct |
36 |
Correct |
239 ms |
24844 KB |
Output is correct |
37 |
Correct |
277 ms |
24660 KB |
Output is correct |
38 |
Correct |
177 ms |
24148 KB |
Output is correct |
39 |
Correct |
75 ms |
14932 KB |
Output is correct |
40 |
Correct |
3 ms |
860 KB |
Output is correct |
41 |
Correct |
4 ms |
1116 KB |
Output is correct |
42 |
Correct |
2 ms |
1016 KB |
Output is correct |
43 |
Correct |
3 ms |
988 KB |
Output is correct |
44 |
Correct |
269 ms |
25344 KB |
Output is correct |
45 |
Correct |
328 ms |
25372 KB |
Output is correct |
46 |
Correct |
315 ms |
25164 KB |
Output is correct |
47 |
Correct |
332 ms |
25472 KB |
Output is correct |
48 |
Correct |
206 ms |
25168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
460 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
4 ms |
1116 KB |
Output is correct |
27 |
Correct |
3 ms |
1076 KB |
Output is correct |
28 |
Correct |
4 ms |
1116 KB |
Output is correct |
29 |
Correct |
4 ms |
1112 KB |
Output is correct |
30 |
Correct |
3 ms |
860 KB |
Output is correct |
31 |
Correct |
3 ms |
860 KB |
Output is correct |
32 |
Correct |
4 ms |
860 KB |
Output is correct |
33 |
Correct |
3 ms |
1116 KB |
Output is correct |
34 |
Correct |
4 ms |
1116 KB |
Output is correct |
35 |
Correct |
1 ms |
604 KB |
Output is correct |
36 |
Correct |
1 ms |
604 KB |
Output is correct |
37 |
Correct |
2 ms |
1036 KB |
Output is correct |
38 |
Correct |
3 ms |
1116 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
1 ms |
600 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
122 ms |
24104 KB |
Output is correct |
51 |
Correct |
94 ms |
16256 KB |
Output is correct |
52 |
Correct |
88 ms |
20048 KB |
Output is correct |
53 |
Correct |
158 ms |
24144 KB |
Output is correct |
54 |
Correct |
123 ms |
24144 KB |
Output is correct |
55 |
Correct |
106 ms |
24120 KB |
Output is correct |
56 |
Correct |
0 ms |
344 KB |
Output is correct |
57 |
Correct |
0 ms |
344 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
1 ms |
348 KB |
Output is correct |
60 |
Correct |
1 ms |
604 KB |
Output is correct |
61 |
Correct |
147 ms |
24404 KB |
Output is correct |
62 |
Correct |
148 ms |
23632 KB |
Output is correct |
63 |
Correct |
124 ms |
17768 KB |
Output is correct |
64 |
Correct |
204 ms |
24400 KB |
Output is correct |
65 |
Correct |
125 ms |
24144 KB |
Output is correct |
66 |
Correct |
1 ms |
456 KB |
Output is correct |
67 |
Correct |
0 ms |
348 KB |
Output is correct |
68 |
Correct |
1 ms |
348 KB |
Output is correct |
69 |
Correct |
0 ms |
348 KB |
Output is correct |
70 |
Correct |
4 ms |
940 KB |
Output is correct |
71 |
Correct |
1 ms |
604 KB |
Output is correct |
72 |
Correct |
2 ms |
604 KB |
Output is correct |
73 |
Correct |
231 ms |
23712 KB |
Output is correct |
74 |
Correct |
217 ms |
22608 KB |
Output is correct |
75 |
Correct |
239 ms |
24844 KB |
Output is correct |
76 |
Correct |
277 ms |
24660 KB |
Output is correct |
77 |
Correct |
177 ms |
24148 KB |
Output is correct |
78 |
Correct |
75 ms |
14932 KB |
Output is correct |
79 |
Correct |
3 ms |
860 KB |
Output is correct |
80 |
Correct |
4 ms |
1116 KB |
Output is correct |
81 |
Correct |
2 ms |
1016 KB |
Output is correct |
82 |
Correct |
3 ms |
988 KB |
Output is correct |
83 |
Correct |
269 ms |
25344 KB |
Output is correct |
84 |
Correct |
328 ms |
25372 KB |
Output is correct |
85 |
Correct |
315 ms |
25164 KB |
Output is correct |
86 |
Correct |
332 ms |
25472 KB |
Output is correct |
87 |
Correct |
206 ms |
25168 KB |
Output is correct |
88 |
Correct |
280 ms |
27224 KB |
Output is correct |
89 |
Correct |
258 ms |
27236 KB |
Output is correct |
90 |
Correct |
245 ms |
27216 KB |
Output is correct |
91 |
Correct |
275 ms |
27056 KB |
Output is correct |
92 |
Correct |
276 ms |
25684 KB |
Output is correct |
93 |
Correct |
334 ms |
25936 KB |
Output is correct |
94 |
Correct |
300 ms |
25940 KB |
Output is correct |
95 |
Correct |
187 ms |
26912 KB |
Output is correct |
96 |
Correct |
158 ms |
27080 KB |
Output is correct |
97 |
Correct |
122 ms |
27240 KB |
Output is correct |
98 |
Correct |
105 ms |
25776 KB |
Output is correct |
99 |
Correct |
125 ms |
26100 KB |
Output is correct |