Submission #711306

# Submission time Handle Problem Language Result Execution time Memory
711306 2023-03-16T14:31:05 Z kostia244 Team Contest (JOI22_team) C++17
73 / 100
2000 ms 8524 KB
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
const int inf = 1<<28;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<array<int, 3>> a(n);
    vector<int> Y, yid(n), A(n, -inf), B(n, inf);
    for(auto &[x, y, z] : a) {
        cin >> x >> y >> z;
        Y.push_back(y);
    }
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    sort(all(Y));
    Y.erase(unique(all(Y)), Y.end());
    for(int i = 0; i < n; i++)
        yid[i] = lower_bound(all(Y), a[i][1]) - Y.begin();
    n = a.size();

    auto add = [&](int i) {
        int y_id = yid[i];
        int z = a[i][2];
        B[y_id] = min(B[y_id], z);
        A[y_id] = max(A[y_id], z);
    };
    auto query = [&](int ly, int z) {
        int ans = -inf;
        int zmax = -inf;
        for(int i = 0; i < Y.size(); i++) {
            if(zmax > z && i > ly && (zmax > B[i])) {
                ans = max(ans, zmax + Y[i]);
            }
            zmax = max(zmax, A[i]);
        }
        return ans;
    };

    int ans = -1;
    for(int j = 0, i = 0; i < n; i++) {//z
        while(a[j][0] < a[i][0]) {
            add(j++);
        }
        ans = max(ans, a[i][0] + query(yid[i], a[i][2]));
    }
    cout << ans << '\n';
}

Compilation message

team.cpp: In lambda function:
team.cpp:34:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = 0; i < Y.size(); i++) {
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 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 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 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 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 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 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 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 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 41 ms 340 KB Output is correct
27 Correct 22 ms 340 KB Output is correct
28 Correct 19 ms 340 KB Output is correct
29 Correct 12 ms 440 KB Output is correct
30 Correct 7 ms 340 KB Output is correct
31 Correct 9 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 21 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 10 ms 468 KB Output is correct
38 Correct 9 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 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 45 ms 4908 KB Output is correct
12 Correct 31 ms 3288 KB Output is correct
13 Correct 34 ms 3800 KB Output is correct
14 Correct 46 ms 4908 KB Output is correct
15 Correct 40 ms 4992 KB Output is correct
16 Correct 34 ms 4980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 45 ms 4908 KB Output is correct
12 Correct 31 ms 3288 KB Output is correct
13 Correct 34 ms 3800 KB Output is correct
14 Correct 46 ms 4908 KB Output is correct
15 Correct 40 ms 4992 KB Output is correct
16 Correct 34 ms 4980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 52 ms 4944 KB Output is correct
23 Correct 54 ms 4912 KB Output is correct
24 Correct 39 ms 3544 KB Output is correct
25 Correct 51 ms 4880 KB Output is correct
26 Correct 43 ms 4904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 45 ms 4908 KB Output is correct
12 Correct 31 ms 3288 KB Output is correct
13 Correct 34 ms 3800 KB Output is correct
14 Correct 46 ms 4908 KB Output is correct
15 Correct 40 ms 4992 KB Output is correct
16 Correct 34 ms 4980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 52 ms 4944 KB Output is correct
23 Correct 54 ms 4912 KB Output is correct
24 Correct 39 ms 3544 KB Output is correct
25 Correct 51 ms 4880 KB Output is correct
26 Correct 43 ms 4904 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 216 KB Output is correct
31 Correct 4 ms 344 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 148 ms 4820 KB Output is correct
35 Correct 128 ms 6100 KB Output is correct
36 Correct 124 ms 6508 KB Output is correct
37 Correct 94 ms 6604 KB Output is correct
38 Correct 48 ms 6396 KB Output is correct
39 Correct 52 ms 3852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 45 ms 4908 KB Output is correct
12 Correct 31 ms 3288 KB Output is correct
13 Correct 34 ms 3800 KB Output is correct
14 Correct 46 ms 4908 KB Output is correct
15 Correct 40 ms 4992 KB Output is correct
16 Correct 34 ms 4980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 52 ms 4944 KB Output is correct
23 Correct 54 ms 4912 KB Output is correct
24 Correct 39 ms 3544 KB Output is correct
25 Correct 51 ms 4880 KB Output is correct
26 Correct 43 ms 4904 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 216 KB Output is correct
31 Correct 4 ms 344 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 148 ms 4820 KB Output is correct
35 Correct 128 ms 6100 KB Output is correct
36 Correct 124 ms 6508 KB Output is correct
37 Correct 94 ms 6604 KB Output is correct
38 Correct 48 ms 6396 KB Output is correct
39 Correct 52 ms 3852 KB Output is correct
40 Correct 7 ms 328 KB Output is correct
41 Correct 10 ms 468 KB Output is correct
42 Correct 8 ms 500 KB Output is correct
43 Correct 9 ms 468 KB Output is correct
44 Correct 842 ms 6988 KB Output is correct
45 Correct 751 ms 7044 KB Output is correct
46 Correct 913 ms 7020 KB Output is correct
47 Correct 805 ms 6988 KB Output is correct
48 Correct 78 ms 6988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 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 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 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 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 41 ms 340 KB Output is correct
27 Correct 22 ms 340 KB Output is correct
28 Correct 19 ms 340 KB Output is correct
29 Correct 12 ms 440 KB Output is correct
30 Correct 7 ms 340 KB Output is correct
31 Correct 9 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 21 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 10 ms 468 KB Output is correct
38 Correct 9 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 0 ms 212 KB Output is correct
42 Correct 0 ms 212 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 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 45 ms 4908 KB Output is correct
51 Correct 31 ms 3288 KB Output is correct
52 Correct 34 ms 3800 KB Output is correct
53 Correct 46 ms 4908 KB Output is correct
54 Correct 40 ms 4992 KB Output is correct
55 Correct 34 ms 4980 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 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 52 ms 4944 KB Output is correct
62 Correct 54 ms 4912 KB Output is correct
63 Correct 39 ms 3544 KB Output is correct
64 Correct 51 ms 4880 KB Output is correct
65 Correct 43 ms 4904 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 216 KB Output is correct
70 Correct 4 ms 344 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 148 ms 4820 KB Output is correct
74 Correct 128 ms 6100 KB Output is correct
75 Correct 124 ms 6508 KB Output is correct
76 Correct 94 ms 6604 KB Output is correct
77 Correct 48 ms 6396 KB Output is correct
78 Correct 52 ms 3852 KB Output is correct
79 Correct 7 ms 328 KB Output is correct
80 Correct 10 ms 468 KB Output is correct
81 Correct 8 ms 500 KB Output is correct
82 Correct 9 ms 468 KB Output is correct
83 Correct 842 ms 6988 KB Output is correct
84 Correct 751 ms 7044 KB Output is correct
85 Correct 913 ms 7020 KB Output is correct
86 Correct 805 ms 6988 KB Output is correct
87 Correct 78 ms 6988 KB Output is correct
88 Execution timed out 2054 ms 8524 KB Time limit exceeded
89 Halted 0 ms 0 KB -