Submission #950005

#TimeUsernameProblemLanguageResultExecution timeMemory
950005hotboy2703Team Contest (JOI22_team)C++14
100 / 100
77 ms15068 KiB
#include<bits/stdc++.h> using ll = long long; using namespace std; #define pll pair <ll,ll> #define fi first #define se second #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) #define MP make_pair ll t; ll n; const ll MAXN=1.5e5; bool del[MAXN+100]; pll a[3][MAXN+100]; ll val[3][MAXN+100]; int main(){ ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr); cin>>n; for (ll i = 1;i <= n;i ++){ for (ll j = 0;j < 3;j ++){ cin>>a[j][i].fi; a[j][i].se=i; val[j][i] = a[j][i].fi; } } for (ll j = 0;j < 3;j ++){ sort(a[j]+1,a[j]+1+n); } ll p[3]; p[0]=p[1]=p[2]=n; for (ll i = 1;i <= n;i ++){ for (ll j = 0;j < 3;j ++){ while (del[a[j][p[j]].se])p[j]--; } bool ok = 1; for (ll j1 = 0;j1 < 3 && ok;j1 ++){ for (ll j2 = 0;j2 < 3 && ok;j2 ++){ if (j2==j1)continue; ll bad = a[j1][p[j1]].se; ll good = a[j2][p[j2]].se; if (val[j2][bad] == val[j2][good]){ del[bad] = 1; // cout<<i<<' '<<bad<<' '<<good<<endl; ok = 0; } } } if (ok){ ll sum = 0; for (ll j = 0;j < 3;j ++){ sum += a[j][p[j]].fi; } cout<<sum; return 0; } } cout<<-1<<'\n'; }
#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...