답안 #1058743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058743 2024-08-14T13:16:34 Z Boas Team Contest (JOI22_team) C++17
37 / 100
2000 ms 189524 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;

#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
// #define int long long
#define INF ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define existsIn(x, l) (count(ALL(l), x) > 0)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define F first
#define S second
#define var const auto &
#define foreach(l) for (var e : l)

typedef int8_t in8;
typedef int16_t in16;
typedef int32_t in32;
typedef int64_t in64;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vi::iterator viit;
typedef si::iterator siit;

void solve()
{
    int n;
    cin >> n;
    viii beavers(n);
    map<int, int> xCom;
    map<int, int> yCom;
    si xs, ys;
    for (auto &[x, y, z] : beavers)
    {
        cin >> x >> y >> z;
        xs.insert(x);
        ys.insert(y);
    }
    vi xComRev(sz(xs) + 1), yComRev(sz(ys) + 1);
    auto it = xs.begin();
    for (int i = 1; i <= sz(xs); i++)
    {
        xCom[*it] = i;
        xComRev[i] = *it;
        it++;
    }
    it = ys.begin();
    for (int i = 1; i <= sz(ys); i++)
    {
        yCom[*it] = i;
        yComRev[i] = *it;
        it++;
    }
    for (auto &[x, y, z] : beavers)
    {
        x = xCom[x];
        y = yCom[y];
    }
    vvi z(sz(xs) + 1, vi(sz(ys) + 1, -INF));
    vvi maxZ = z, minZ = z;
    for (var[x, y, Z] : beavers)
    {
        z[x][y] = max(z[x][y], Z);
    }
    for (int x = 1; x <= sz(xs); x++)
    {
        for (int y = 1; y <= sz(ys); y++)
        {
            maxZ[x][y] = max({maxZ[x - 1][y], maxZ[x][y - 1], z[x][y]});
        }
    }
    int res = -1;
    loop(n, i)
    {
        var[x1, y1, z1] = beavers[i];
        loop(n, j)
        {
            var[x2, y2, z2] = beavers[j];
            if (x1 <= x2)
                continue;
            if (y2 <= y1)
                continue;
            int z3 = maxZ[x1 - 1][y2 - 1];
            if (z3 > max(z1, z2))
                res = max(res, xComRev[x1] + yComRev[y2] + z3);
        }
    }
    cout << res << endl;
}

signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}
# 결과 실행 시간 메모리 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 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 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 1372 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 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 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 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 1372 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
26 Correct 139 ms 189524 KB Output is correct
27 Correct 81 ms 69968 KB Output is correct
28 Correct 76 ms 62776 KB Output is correct
29 Correct 60 ms 38748 KB Output is correct
30 Correct 33 ms 29272 KB Output is correct
31 Correct 55 ms 14428 KB Output is correct
32 Correct 49 ms 1624 KB Output is correct
33 Correct 18 ms 11096 KB Output is correct
34 Correct 112 ms 189264 KB Output is correct
35 Correct 1 ms 1628 KB Output is correct
36 Correct 1 ms 1628 KB Output is correct
37 Correct 26 ms 21852 KB Output is correct
38 Correct 20 ms 21852 KB Output is correct
39 Correct 11 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 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 Execution timed out 2099 ms 2236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 Execution timed out 2099 ms 2236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 Execution timed out 2099 ms 2236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 Execution timed out 2099 ms 2236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 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 1372 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
26 Correct 139 ms 189524 KB Output is correct
27 Correct 81 ms 69968 KB Output is correct
28 Correct 76 ms 62776 KB Output is correct
29 Correct 60 ms 38748 KB Output is correct
30 Correct 33 ms 29272 KB Output is correct
31 Correct 55 ms 14428 KB Output is correct
32 Correct 49 ms 1624 KB Output is correct
33 Correct 18 ms 11096 KB Output is correct
34 Correct 112 ms 189264 KB Output is correct
35 Correct 1 ms 1628 KB Output is correct
36 Correct 1 ms 1628 KB Output is correct
37 Correct 26 ms 21852 KB Output is correct
38 Correct 20 ms 21852 KB Output is correct
39 Correct 11 ms 344 KB Output is correct
40 Correct 0 ms 348 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 Execution timed out 2099 ms 2236 KB Time limit exceeded
51 Halted 0 ms 0 KB -