답안 #713664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713664 2023-03-22T19:16:22 Z mraron Team Contest (JOI22_team) C++14
100 / 100
101 ms 7792 KB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ins insert

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
    T val=0;
    char c;
    
    bool neg=false;
    while((c=gc()) && !(c>='0' && c<='9')) {
        neg|=c=='-';
    }

    do {
        val=(val*10)+c-'0';
    } while((c=gc()) && (c>='0' && c<='9'));

    return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

int n;
vector<array<int,3>> t;

int main() {
    IO;
    cin>>n;
    t.resize(n);
    for(int i=0;i<n;++i) cin>>t[i][0]>>t[i][1]>>t[i][2];
    sort(t.begin(), t.end());
    
    array<vector<int>,3> ord({vector<int>(n), vector<int>(n), vector<int>(n)});
    for(int i=0;i<3;++i) {
        iota(all(ord[i]), 0);
        sort(all(ord[i]), [&](int x, int y)->bool {
            return t[x][i]<t[y][i];
        });
    } 
    
    array<int,3> inds={n-1, n-1, n-1};
    while(min({inds[0], inds[1], inds[2]})>=0) {
        //~ cerr<<inds[0]<<" "<<inds[1]<<" "<<inds[2]<<"\n";
        for(int i=0;i<3;++i) {
            bool any=false;
            for(int j=0;!any&&j<3;++j) {
                if(i!=j) {
                    any|=t[ord[i][inds[i]]][j]>=t[ord[j][inds[j]]][j];
                } 
            }
            if(any) {
                inds[i]--;
                goto end;
            }
        }
        cout<<t[ord[0][inds[0]]][0]+t[ord[1][inds[1]]][1]+t[ord[2][inds[2]]][2]<<"\n";
        return 0;
        end:;
    }
    
    cout<<"-1\n";
    
   
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 228 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 228 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 3 ms 328 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 456 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 324 KB Output is correct
37 Correct 2 ms 456 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 51 ms 4620 KB Output is correct
12 Correct 32 ms 3252 KB Output is correct
13 Correct 46 ms 3896 KB Output is correct
14 Correct 51 ms 4684 KB Output is correct
15 Correct 48 ms 4684 KB Output is correct
16 Correct 49 ms 4636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 51 ms 4620 KB Output is correct
12 Correct 32 ms 3252 KB Output is correct
13 Correct 46 ms 3896 KB Output is correct
14 Correct 51 ms 4684 KB Output is correct
15 Correct 48 ms 4684 KB Output is correct
16 Correct 49 ms 4636 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 57 ms 4872 KB Output is correct
23 Correct 51 ms 4580 KB Output is correct
24 Correct 41 ms 3636 KB Output is correct
25 Correct 60 ms 4880 KB Output is correct
26 Correct 49 ms 4868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 51 ms 4620 KB Output is correct
12 Correct 32 ms 3252 KB Output is correct
13 Correct 46 ms 3896 KB Output is correct
14 Correct 51 ms 4684 KB Output is correct
15 Correct 48 ms 4684 KB Output is correct
16 Correct 49 ms 4636 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 57 ms 4872 KB Output is correct
23 Correct 51 ms 4580 KB Output is correct
24 Correct 41 ms 3636 KB Output is correct
25 Correct 60 ms 4880 KB Output is correct
26 Correct 49 ms 4868 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 416 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 64 ms 5176 KB Output is correct
35 Correct 70 ms 4868 KB Output is correct
36 Correct 74 ms 5452 KB Output is correct
37 Correct 66 ms 5372 KB Output is correct
38 Correct 54 ms 5232 KB Output is correct
39 Correct 32 ms 3396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 51 ms 4620 KB Output is correct
12 Correct 32 ms 3252 KB Output is correct
13 Correct 46 ms 3896 KB Output is correct
14 Correct 51 ms 4684 KB Output is correct
15 Correct 48 ms 4684 KB Output is correct
16 Correct 49 ms 4636 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 57 ms 4872 KB Output is correct
23 Correct 51 ms 4580 KB Output is correct
24 Correct 41 ms 3636 KB Output is correct
25 Correct 60 ms 4880 KB Output is correct
26 Correct 49 ms 4868 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 416 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 64 ms 5176 KB Output is correct
35 Correct 70 ms 4868 KB Output is correct
36 Correct 74 ms 5452 KB Output is correct
37 Correct 66 ms 5372 KB Output is correct
38 Correct 54 ms 5232 KB Output is correct
39 Correct 32 ms 3396 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 83 ms 5824 KB Output is correct
45 Correct 83 ms 5904 KB Output is correct
46 Correct 76 ms 5792 KB Output is correct
47 Correct 76 ms 5916 KB Output is correct
48 Correct 59 ms 5768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 228 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 3 ms 328 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 456 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 324 KB Output is correct
37 Correct 2 ms 456 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 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 316 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 320 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 320 KB Output is correct
48 Correct 1 ms 320 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 51 ms 4620 KB Output is correct
51 Correct 32 ms 3252 KB Output is correct
52 Correct 46 ms 3896 KB Output is correct
53 Correct 51 ms 4684 KB Output is correct
54 Correct 48 ms 4684 KB Output is correct
55 Correct 49 ms 4636 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 57 ms 4872 KB Output is correct
62 Correct 51 ms 4580 KB Output is correct
63 Correct 41 ms 3636 KB Output is correct
64 Correct 60 ms 4880 KB Output is correct
65 Correct 49 ms 4868 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 2 ms 416 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 64 ms 5176 KB Output is correct
74 Correct 70 ms 4868 KB Output is correct
75 Correct 74 ms 5452 KB Output is correct
76 Correct 66 ms 5372 KB Output is correct
77 Correct 54 ms 5232 KB Output is correct
78 Correct 32 ms 3396 KB Output is correct
79 Correct 2 ms 332 KB Output is correct
80 Correct 2 ms 340 KB Output is correct
81 Correct 2 ms 340 KB Output is correct
82 Correct 2 ms 340 KB Output is correct
83 Correct 83 ms 5824 KB Output is correct
84 Correct 83 ms 5904 KB Output is correct
85 Correct 76 ms 5792 KB Output is correct
86 Correct 76 ms 5916 KB Output is correct
87 Correct 59 ms 5768 KB Output is correct
88 Correct 101 ms 7792 KB Output is correct
89 Correct 93 ms 7692 KB Output is correct
90 Correct 98 ms 7724 KB Output is correct
91 Correct 96 ms 7696 KB Output is correct
92 Correct 88 ms 6172 KB Output is correct
93 Correct 100 ms 6628 KB Output is correct
94 Correct 88 ms 6460 KB Output is correct
95 Correct 74 ms 7568 KB Output is correct
96 Correct 67 ms 7656 KB Output is correct
97 Correct 65 ms 7700 KB Output is correct
98 Correct 52 ms 6296 KB Output is correct
99 Correct 69 ms 6288 KB Output is correct