Submission #688086

# Submission time Handle Problem Language Result Execution time Memory
688086 2023-01-27T06:45:34 Z Darren0724 Team Contest (JOI22_team) C++17
9 / 100
58 ms 5148 KB
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
const int INF=1e9;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<pair<int,pii>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].x>>v[i].y.x>>v[i].y.y;
    }
    sort(all(v));
    vector<pii> q;
    set<pii> s,c;
    int ans=-1;
    for(int i=0;i<n;i++){
        pii t=v[i].y;
        if(i>0&&v[i].x>v[i-1].x){
            for(auto t:q){
                auto it=c.lower_bound(t);
                if(it!=c.begin()&&(*prev(it)).y>t.y){
                    continue;
                }
                c.insert(t);
                it=c.lower_bound(t);
                it++;
                while(it!=c.end()){
                    if(t.y>(*it).y){
                        c.erase(it);
                        it=c.lower_bound(t);
                        it++;
                    }
                    else{
                        break;
                    }
                }

            }
            for(auto t:q){
                auto it=c.upper_bound({t.x,0});
                int tmp=-1;
                if(it!=c.begin()&&(*prev(it)).y>t.y){
                    tmp=(*prev(it)).y;
                }
                if(tmp==-1){
                    continue;
                }
                it=s.lower_bound({t.x,tmp});
                if(it!=s.begin()&&(*prev(it)).y>tmp){
                    continue;
                }
                s.insert({t.x,tmp});
                it=s.lower_bound({t.x,tmp});
                while(it!=s.begin()){
                    it--;
                    if((*it).y<tmp){
                        s.erase(it);
                        it=s.lower_bound({t.x,tmp});
                    }
                }
            }
            q.clear();
        }
        q.push_back(v[i].y);
        auto it=s.upper_bound({t.x,INF});
        if(it==s.end()||(*it).y<=t.y){
            continue;
        }
        ans=max(ans,v[i].x+(*it).x+(*it).y);
    }
    cout<<ans<<endl;

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 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 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 320 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 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 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 320 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 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 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 41 ms 3340 KB Output is correct
12 Correct 27 ms 2604 KB Output is correct
13 Correct 30 ms 3048 KB Output is correct
14 Correct 37 ms 3608 KB Output is correct
15 Correct 32 ms 4112 KB Output is correct
16 Correct 29 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 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 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 41 ms 3340 KB Output is correct
12 Correct 27 ms 2604 KB Output is correct
13 Correct 30 ms 3048 KB Output is correct
14 Correct 37 ms 3608 KB Output is correct
15 Correct 32 ms 4112 KB Output is correct
16 Correct 29 ms 5148 KB Output is correct
17 Correct 1 ms 316 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 58 ms 3348 KB Output is correct
23 Incorrect 46 ms 3096 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 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 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 41 ms 3340 KB Output is correct
12 Correct 27 ms 2604 KB Output is correct
13 Correct 30 ms 3048 KB Output is correct
14 Correct 37 ms 3608 KB Output is correct
15 Correct 32 ms 4112 KB Output is correct
16 Correct 29 ms 5148 KB Output is correct
17 Correct 1 ms 316 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 58 ms 3348 KB Output is correct
23 Incorrect 46 ms 3096 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 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 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 41 ms 3340 KB Output is correct
12 Correct 27 ms 2604 KB Output is correct
13 Correct 30 ms 3048 KB Output is correct
14 Correct 37 ms 3608 KB Output is correct
15 Correct 32 ms 4112 KB Output is correct
16 Correct 29 ms 5148 KB Output is correct
17 Correct 1 ms 316 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 58 ms 3348 KB Output is correct
23 Incorrect 46 ms 3096 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 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 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 320 KB Output isn't correct
15 Halted 0 ms 0 KB -