답안 #978507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978507 2024-05-09T09:20:13 Z vjudge1 Team Contest (JOI22_team) C++17
55 / 100
1405 ms 14756 KB
#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;

int tt = 1, n;
ll x[200005], y[200005], z[200005];
pair<pair<ll, ll>, pair<ll, int>> p[200005];
vector<int> g1[3003], g2[3003], g3[3003];
ll mx;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> y[i] >> z[i];
		p[i] = {{x[i], y[i]}, {z[i], i}};
	}
    if(n <= 4000){
        sort(p + 1, p + n + 1);
        for(int i = 3; i <= n; i++){
            set<ll> st;
            vector<pair<ll, ll>> v;
            for(int j = i - 1; j >= 1; j--){
                if(p[i].first.first != p[j].first.first)
                    v.push_back({p[j].first.second, j});
            }
            sort(v.begin(), v.end());
            // for(int j = 0; j < v.size(); j++){
            // 	if(j == 0) mx[j] = p[v[j].second].second.first;
            // 	else mx[j] = max(mx[j - 1], p[v[j].second].second.first);
            // }
            int last = 0;
            for(int j = 1; j < v.size(); j++){
                while(last < j && v[last].first != v[j].first){
                    st.insert(p[v[last].second].second.first);
                    last++;
                }
                if(!st.empty() && p[v[j].second].second.first < *st.rbegin() && v[j].first > p[i].first.second && p[i].second.first < *st.rbegin()){
                    mx = max(mx, p[i].first.first + v[j].first + *st.rbegin());
                    // cout << p[i].first.first << " " << v[j].first << " " << *st.rbegin() << "\n";
                }
            }
        }
        if(mx == 0) cout << -1;
        else cout << mx;
        return 0;
    }
    for(int i = 1; i <= n; i++){
        g1[x[i]].push_back(i);
        g2[y[i]].push_back(i);
        g3[z[i]].push_back(i);
    }
    int mxx = 0;
    for(int i = 1; i <= 20; i++){
        for(int j = 1; j <= 20; j++){
            // vector<int> v;
            for(int k = 1; k <= 20; k++){
                int kol1 = 0, kol2 = 0, kol3 = 0;
                for(int to1 : g1[i])
                    if(y[to1] < j && z[to1] < k) kol1++;
                for(int to1 : g2[j])
                    if(x[to1] < i && z[to1] < k) kol2++;
                for(int to1 : g3[k])
                    if(y[to1] < j && x[to1] < i) kol3++;
                if(min({kol1, kol2, kol3}) > 0) 
                    mxx = max(mxx, i + j + k);
            }
        }
    }
    if(mxx == 0) cout << -1;
    else cout << mxx;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:58:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for(int j = 1; j < v.size(); j++){
      |                            ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6780 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 7 ms 6748 KB Output is correct
15 Correct 4 ms 6748 KB Output is correct
16 Correct 5 ms 6744 KB Output is correct
17 Correct 5 ms 6748 KB Output is correct
18 Correct 5 ms 6748 KB Output is correct
19 Correct 4 ms 6748 KB Output is correct
20 Correct 3 ms 6788 KB Output is correct
21 Correct 2 ms 6748 KB Output is correct
22 Correct 5 ms 6808 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 3 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6780 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 7 ms 6748 KB Output is correct
15 Correct 4 ms 6748 KB Output is correct
16 Correct 5 ms 6744 KB Output is correct
17 Correct 5 ms 6748 KB Output is correct
18 Correct 5 ms 6748 KB Output is correct
19 Correct 4 ms 6748 KB Output is correct
20 Correct 3 ms 6788 KB Output is correct
21 Correct 2 ms 6748 KB Output is correct
22 Correct 5 ms 6808 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 3 ms 6748 KB Output is correct
26 Correct 1405 ms 7072 KB Output is correct
27 Correct 1259 ms 7060 KB Output is correct
28 Correct 1286 ms 7064 KB Output is correct
29 Correct 1143 ms 7072 KB Output is correct
30 Correct 538 ms 6816 KB Output is correct
31 Correct 1099 ms 7100 KB Output is correct
32 Correct 828 ms 7132 KB Output is correct
33 Correct 71 ms 6748 KB Output is correct
34 Correct 821 ms 7004 KB Output is correct
35 Correct 25 ms 6748 KB Output is correct
36 Correct 26 ms 6832 KB Output is correct
37 Correct 618 ms 6816 KB Output is correct
38 Correct 611 ms 6840 KB Output is correct
39 Correct 119 ms 6944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 432 ms 13400 KB Output is correct
12 Correct 261 ms 11160 KB Output is correct
13 Correct 223 ms 11448 KB Output is correct
14 Correct 377 ms 14612 KB Output is correct
15 Correct 281 ms 14192 KB Output is correct
16 Correct 186 ms 14284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 432 ms 13400 KB Output is correct
12 Correct 261 ms 11160 KB Output is correct
13 Correct 223 ms 11448 KB Output is correct
14 Correct 377 ms 14612 KB Output is correct
15 Correct 281 ms 14192 KB Output is correct
16 Correct 186 ms 14284 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 3 ms 6744 KB Output is correct
21 Correct 121 ms 6864 KB Output is correct
22 Correct 1008 ms 14676 KB Output is correct
23 Correct 626 ms 14216 KB Output is correct
24 Correct 535 ms 11356 KB Output is correct
25 Correct 675 ms 14756 KB Output is correct
26 Correct 374 ms 14144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 432 ms 13400 KB Output is correct
12 Correct 261 ms 11160 KB Output is correct
13 Correct 223 ms 11448 KB Output is correct
14 Correct 377 ms 14612 KB Output is correct
15 Correct 281 ms 14192 KB Output is correct
16 Correct 186 ms 14284 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 3 ms 6744 KB Output is correct
21 Correct 121 ms 6864 KB Output is correct
22 Correct 1008 ms 14676 KB Output is correct
23 Correct 626 ms 14216 KB Output is correct
24 Correct 535 ms 11356 KB Output is correct
25 Correct 675 ms 14756 KB Output is correct
26 Correct 374 ms 14144 KB Output is correct
27 Correct 5 ms 6744 KB Output is correct
28 Correct 4 ms 6748 KB Output is correct
29 Correct 3 ms 6792 KB Output is correct
30 Correct 4 ms 6748 KB Output is correct
31 Correct 781 ms 7012 KB Output is correct
32 Correct 25 ms 6820 KB Output is correct
33 Correct 25 ms 6744 KB Output is correct
34 Incorrect 42 ms 14672 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 432 ms 13400 KB Output is correct
12 Correct 261 ms 11160 KB Output is correct
13 Correct 223 ms 11448 KB Output is correct
14 Correct 377 ms 14612 KB Output is correct
15 Correct 281 ms 14192 KB Output is correct
16 Correct 186 ms 14284 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 3 ms 6744 KB Output is correct
21 Correct 121 ms 6864 KB Output is correct
22 Correct 1008 ms 14676 KB Output is correct
23 Correct 626 ms 14216 KB Output is correct
24 Correct 535 ms 11356 KB Output is correct
25 Correct 675 ms 14756 KB Output is correct
26 Correct 374 ms 14144 KB Output is correct
27 Correct 5 ms 6744 KB Output is correct
28 Correct 4 ms 6748 KB Output is correct
29 Correct 3 ms 6792 KB Output is correct
30 Correct 4 ms 6748 KB Output is correct
31 Correct 781 ms 7012 KB Output is correct
32 Correct 25 ms 6820 KB Output is correct
33 Correct 25 ms 6744 KB Output is correct
34 Incorrect 42 ms 14672 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6780 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 7 ms 6748 KB Output is correct
15 Correct 4 ms 6748 KB Output is correct
16 Correct 5 ms 6744 KB Output is correct
17 Correct 5 ms 6748 KB Output is correct
18 Correct 5 ms 6748 KB Output is correct
19 Correct 4 ms 6748 KB Output is correct
20 Correct 3 ms 6788 KB Output is correct
21 Correct 2 ms 6748 KB Output is correct
22 Correct 5 ms 6808 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 3 ms 6748 KB Output is correct
26 Correct 1405 ms 7072 KB Output is correct
27 Correct 1259 ms 7060 KB Output is correct
28 Correct 1286 ms 7064 KB Output is correct
29 Correct 1143 ms 7072 KB Output is correct
30 Correct 538 ms 6816 KB Output is correct
31 Correct 1099 ms 7100 KB Output is correct
32 Correct 828 ms 7132 KB Output is correct
33 Correct 71 ms 6748 KB Output is correct
34 Correct 821 ms 7004 KB Output is correct
35 Correct 25 ms 6748 KB Output is correct
36 Correct 26 ms 6832 KB Output is correct
37 Correct 618 ms 6816 KB Output is correct
38 Correct 611 ms 6840 KB Output is correct
39 Correct 119 ms 6944 KB Output is correct
40 Correct 2 ms 6744 KB Output is correct
41 Correct 1 ms 6748 KB Output is correct
42 Correct 1 ms 6748 KB Output is correct
43 Correct 1 ms 6748 KB Output is correct
44 Correct 1 ms 6748 KB Output is correct
45 Correct 1 ms 6748 KB Output is correct
46 Correct 1 ms 6748 KB Output is correct
47 Correct 1 ms 6748 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 6748 KB Output is correct
50 Correct 432 ms 13400 KB Output is correct
51 Correct 261 ms 11160 KB Output is correct
52 Correct 223 ms 11448 KB Output is correct
53 Correct 377 ms 14612 KB Output is correct
54 Correct 281 ms 14192 KB Output is correct
55 Correct 186 ms 14284 KB Output is correct
56 Correct 2 ms 6748 KB Output is correct
57 Correct 1 ms 6748 KB Output is correct
58 Correct 1 ms 6748 KB Output is correct
59 Correct 3 ms 6744 KB Output is correct
60 Correct 121 ms 6864 KB Output is correct
61 Correct 1008 ms 14676 KB Output is correct
62 Correct 626 ms 14216 KB Output is correct
63 Correct 535 ms 11356 KB Output is correct
64 Correct 675 ms 14756 KB Output is correct
65 Correct 374 ms 14144 KB Output is correct
66 Correct 5 ms 6744 KB Output is correct
67 Correct 4 ms 6748 KB Output is correct
68 Correct 3 ms 6792 KB Output is correct
69 Correct 4 ms 6748 KB Output is correct
70 Correct 781 ms 7012 KB Output is correct
71 Correct 25 ms 6820 KB Output is correct
72 Correct 25 ms 6744 KB Output is correct
73 Incorrect 42 ms 14672 KB Output isn't correct
74 Halted 0 ms 0 KB -