답안 #795170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
795170 2023-07-27T07:15:50 Z vjudge1 Team Contest (JOI22_team) C++17
37 / 100
2000 ms 376700 KB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

struct My{
    int x, y, z;

    bool operator < (My &b) {
        return x == b.x ? (y == b.y ? z < b.z : y < b.y) : x < b.x;
    }
};

map < int , map < int, int > > mp;


int get(int x, int y) {
    auto it = mp.lower_bound(x);
    if(it == mp.begin()) {
        return 0;
    }
    -- it;
    auto it2 = it->second.lower_bound(y);
    if(it2 == it->second.begin()) {
        return 0;
    }
    -- it2;
    return it2->second;
}

main() {
#ifdef Home
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Home
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m, k;
    cin >> n;
    vector < My > V(n);
    for(auto &[x, y, z] : V) {
        cin >> x >> y >> z;
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < n; ++ i) {
        auto it = mp.find(V[i].x);
        if(it == mp.end()) {
            mp[V[i].x];
            it = mp.find(V[i].x);
        }
        auto it2 = it->second.find(V[i].y);
        if(it2 == it->second.end()) {
            it->second[V[i].y] = V[i].z;
        } else {
            it2->second = max(it2->second, V[i].z);
        }
        if(i + 1 < n && V[i].x == V[i + 1].x) {
            continue;
        }
        if(it != mp.begin()) {
            auto pre_mp = prev(it);
            for(auto &[key, val] : pre_mp->second) {
                auto it2 = it->second.find(key);
                if(it2 == it->second.end()) {
                    it->second[key] = val;
                } else {
                    it2->second = max(it2->second, val);
                }
            }
        } 
        int mx = 0;
        for(auto &[key, val] : it->second) {
            mx = max(mx, val);
            val = mx;
        }
    }
    /**
    for(auto &[x, y, z] : V) {
        cout << x << ' ' << y << ' ' << z << '\n';
    }
    cout << '\n';
    for(auto &[key, val] : mp) {
        for(auto &[key2, val2] : val) {
            cout << key << ' ' << key2 << ' ' << val2 << '\n';
        }
    }
    // */
    int ans = 0;
    for(int i = n; i --> 0;) {
        for(int j = i; j --> 0;) {
            if(V[i].x > V[j].x && V[j].y > V[i].y) {
                k = get(V[i].x, V[j].y);
                if(k > V[i].z && k > V[j].z) {
                    ans = max(ans, V[i].x + V[j].y + k);
                }
            }
        }
    }
    cout << (ans ? ans : -1);
} 

Compilation message

team.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main() {
      | ^~~~
team.cpp: In function 'int main()':
team.cpp:44:12: warning: unused variable 'm' [-Wunused-variable]
   44 |     int n, m, k;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 6 ms 2388 KB Output is correct
15 Correct 2 ms 640 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 5 ms 2260 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 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 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 6 ms 2388 KB Output is correct
15 Correct 2 ms 640 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 5 ms 2260 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1411 ms 376700 KB Output is correct
27 Correct 687 ms 158576 KB Output is correct
28 Correct 590 ms 142668 KB Output is correct
29 Correct 379 ms 92256 KB Output is correct
30 Correct 277 ms 64872 KB Output is correct
31 Correct 345 ms 39096 KB Output is correct
32 Correct 166 ms 2516 KB Output is correct
33 Correct 26 ms 620 KB Output is correct
34 Correct 934 ms 375532 KB Output is correct
35 Correct 5 ms 2260 KB Output is correct
36 Correct 6 ms 2376 KB Output is correct
37 Correct 143 ms 42324 KB Output is correct
38 Correct 112 ms 42852 KB Output is correct
39 Correct 19 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 2068 ms 2848 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 2068 ms 2848 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 2068 ms 2848 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 2068 ms 2848 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 6 ms 2388 KB Output is correct
15 Correct 2 ms 640 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 5 ms 2260 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1411 ms 376700 KB Output is correct
27 Correct 687 ms 158576 KB Output is correct
28 Correct 590 ms 142668 KB Output is correct
29 Correct 379 ms 92256 KB Output is correct
30 Correct 277 ms 64872 KB Output is correct
31 Correct 345 ms 39096 KB Output is correct
32 Correct 166 ms 2516 KB Output is correct
33 Correct 26 ms 620 KB Output is correct
34 Correct 934 ms 375532 KB Output is correct
35 Correct 5 ms 2260 KB Output is correct
36 Correct 6 ms 2376 KB Output is correct
37 Correct 143 ms 42324 KB Output is correct
38 Correct 112 ms 42852 KB Output is correct
39 Correct 19 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 316 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 320 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Execution timed out 2068 ms 2848 KB Time limit exceeded
51 Halted 0 ms 0 KB -