답안 #955956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955956 2024-03-31T18:08:26 Z YassirSalama Team Contest (JOI22_team) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
#ifdef IOI
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#else
#define dbg(...) 1337;
#endif
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
signed main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
vector<vector<int>> v(n);
for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    v[i]={a,b,c};
}
sort(all(v),[&](const auto p1,const auto p2){
    if(p1[0]==p2[0]){
        if(p1[1]==p2[1]) return p1[2]>p2[1];
        else return p1[1]>p2[1];
    }
    return p1[0]>p2[0];
});
int ans=0;
// for(auto x:v){
//     dbg(x[0],x[1],x[2])
// }
vector<pair<int,int>> a;
for(int i=0;i<n;i++){
    a.emplace_back(v[i][1],v[i][2]);
}
sort(all(a),greater<pair<int,int>>());
for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
        if(v[j][0]!=v[i][0]) break;
        // dbg(i,j)
        if(find(all(a),make_pair(v[j][1],v[j][2]))!=a.end())
            a.erase(find(all(a),make_pair(v[j][1],v[j][2])));
    }
    // for(auto x:a){
    //     dbg(x.F,x.S)
    // }
    // dbg(a.size(),ans)
    if(a.empty()) break;
    int x=a.size();
    int suff[x];
    for(int i=x-1;i>=0;i--){
        suff[i]=a[i].S;
        if(i!=x-1) suff[i]=max(suff[i],suff[i+1]);
    }
    for(int j=0;j<x;j++){
        int mn=a[j].S;
        // dbg(mn)
        while(j+1<x&&a[j].F==a[j+1].F) mn=min(mn,a[j].S),j++;
        if(j==x) continue;
        int f=suff[j+1];
        if(f>mn&&a[j].F>v[i][1]) ans=max(ans,f+a[j].F+v[i][0]);
    }
}

if(ans==0){
    cout<<-1<<endl;
    return 0;
}
cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -