Submission #633489

# Submission time Handle Problem Language Result Execution time Memory
633489 2022-08-22T15:01:03 Z Astrayt Team Contest (JOI22_team) C++17
0 / 100
2000 ms 212 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define N 100005

struct bev{
    int t, x, y, z;
};
vector<bev> v;

void solve(){
    int n; cin >> n;
    vector<int> ok(n, 1);
    vector<bev> buk[3];
    v.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i].x >> v[i].y >> v[i].z; v[i].t = i;
        buk[0].pb(v[i]);
        buk[1].pb(v[i]);
        buk[2].pb(v[i]);
    }
    sort(buk[0].begin(), buk[0].end(), [](bev a, bev b){return a.x < b.x;});
    sort(buk[1].begin(), buk[1].end(), [](bev a, bev b){return a.y < b.y;});
    sort(buk[2].begin(), buk[2].end(), [](bev a, bev b){return a.z < b.z;});
    int i = n - 1, j = n - 1, k = n - 1, ans = -1;
    while(true){
        while(i >= 0 && !ok[buk[0][i].t]) i--;
        while(j >= 0 && !ok[buk[1][j].t]) j--;
        while(k >= 0 && !ok[buk[2][k].t]) k--;
        if(i < 0 || j < 0 || k < 0) break;
        bev a = buk[0][i], b = buk[1][j], c = buk[2][k];
        bool flag = 1;
        if(a.t == b.t) ok[a.t] = 0, flag = 0;
        else if(b.t == c.t) ok[b.t] = 0, flag = 0;
        else if(a.t == c.t) ok[c.t] = 0, flag = 0;
        if(c.x >= a.x || c.y >= b.y) ok[c.t] = 0, flag = 0;
        if(b.x >= a.x || b.z >= c.z) ok[b.t] = 0, flag = 0;
        if(a.y >= b.y || a.z >= c.z) ok[a.t] = 0, flag = 0;
        if(flag) ans = max(ans, a.x + b.y + c.z);
    }
    cout << ans;
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -