이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ins insert
#ifndef ONLINE_JUDGE
# define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
# define LOG(x) ((void)0)
#endif
using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;
const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);
template<typename T> T getint() {
T val=0;
char c;
bool neg=false;
while((c=gc()) && !(c>='0' && c<='9')) {
neg|=c=='-';
}
do {
val=(val*10)+c-'0';
} while((c=gc()) && (c>='0' && c<='9'));
return val*(neg?-1:1);
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)
int n;
vector<array<int,3>> t;
int main() {
IO;
cin>>n;
t.resize(n);
for(int i=0;i<n;++i) cin>>t[i][0]>>t[i][1]>>t[i][2];
sort(t.begin(), t.end());
array<vector<int>,3> ord({vector<int>(n), vector<int>(n), vector<int>(n)});
for(int i=0;i<3;++i) {
iota(all(ord[i]), 0);
sort(all(ord[i]), [&](int x, int y)->bool {
return t[x][i]<t[y][i];
});
}
array<int,3> inds={n-1, n-1, n-1};
while(min({inds[0], inds[1], inds[2]})>=0) {
//~ cerr<<inds[0]<<" "<<inds[1]<<" "<<inds[2]<<"\n";
for(int i=0;i<3;++i) {
bool any=false;
for(int j=0;!any&&j<3;++j) {
if(i!=j) {
any|=t[ord[i][inds[i]]][j]>=t[ord[j][inds[j]]][j];
}
}
if(any) {
inds[i]--;
goto end;
}
}
cout<<t[ord[0][inds[0]]][0]+t[ord[1][inds[1]]][1]+t[ord[2][inds[2]]][2]<<"\n";
return 0;
end:;
}
cout<<"-1\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |