Submission #1004026

#TimeUsernameProblemLanguageResultExecution timeMemory
1004026edogawa_somethingTeam Contest (JOI22_team)C++17
37 / 100
2101 ms195804 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define all(v) v.begin(),v.end() #define pb push_back #define pow poww const int M=5100; const ll mod=998244353; const ll inf=2e18; const ll dx[]={1,-1,0,0}; const ll dy[]={0,0,1,-1}; ll pow(ll x,ll y){ ll res=1; x%=mod; while(y>0){ if(y%2==1){ res*=x,res%=mod; } x*=x,x%=mod; y/=2; } return res; } ll n,ma[M][M],a[M],b[M],c[M],rv1[M],rv2[M],rv3[M]; int main(){ ios_base::sync_with_stdio(0),cin.tie(0); ll TC=1; //cin>>TC; while(TC--){ cin>>n; set<ll>s1,s2,s3; map<ll,ll>mp; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]>>c[i]; s1.insert(a[i]),s2.insert(b[i]),s3.insert(c[i]); } ll t=0; for(auto it:s1) mp[it]=++t,rv1[t]=it; for(int i=0;i<n;i++) a[i]=mp[a[i]]; t=0,mp.clear(); for(auto it:s2) mp[it]=++t,rv2[t]=it; for(int i=0;i<n;i++) b[i]=mp[b[i]]; mp.clear(),t=0; for(auto it:s3) mp[it]=++t,rv3[t]=it; for(int i=0;i<n;i++) c[i]=mp[c[i]]; mp.clear(),t=0; for(int i=0;i<n;i++) ma[a[i]][b[i]]=max(ma[a[i]][b[i]],c[i]); for(int i=0;i<=n;i++){ for(int j=1;j<=n;j++) ma[i][j]=max(ma[i][j-1],ma[i][j]); } for(int j=0;j<=n;j++){ for(int i=1;i<=n;i++) ma[i][j]=max(ma[i][j],ma[i-1][j]); } ll ans=-1; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j) continue; if(a[i]==a[j]||b[i]==b[j]) continue; if(((a[i]>a[j])^(b[i]>b[j]))==0) continue; if(ma[max(a[i],a[j])-1][max(b[i],b[j])-1]<=max(c[i],c[j])) continue; ans=max(ans,rv1[max(a[i],a[j])]+rv2[max(b[i],b[j])]+rv3[ma[max(a[i],a[j])-1][max(b[i],b[j])-1]]); } } cout<<ans; } return 0; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...