Submission #688118

# Submission time Handle Problem Language Result Execution time Memory
688118 2023-01-27T07:15:44 Z Darren0724 Team Contest (JOI22_team) C++17
0 / 100
0 ms 212 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.y>>v[i].y.x;
    }
    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){
            random_shuffle(all(q));
            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;
                }
                s.insert({t.x,tmp});
                while(s.size()>1){
                    s.erase(s.begin());
                }
            }
            q.clear();
        }
        //cout<<s.size()<<endl;
        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 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -