# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544539 | Jarif_Rahman | Team Contest (JOI22_team) | C++17 | 415 ms | 20756 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indexed_set = tree<T,null_type,greater<T>,rb_tree_tag, tree_order_statistics_node_update>;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<tuple<int, int, int>> v(n);
for(auto &[x, y, z]: v) cin >> x >> y >> z;
sort(v.begin(), v.end());
indexed_set<pair<int, int>> s1, s2;
int cur = 0;
int lsi = 0, ls = -1;
int ans = -1;
for(int i = 0; i < n; i++){
auto [x, y, z] = v[i];
if(x > ls){
ls = x;
for(int j = lsi; j < i; j++){
auto [ig, a, b] = v[j];
if(s1.find(make_pair(a, b)) != s1.end()) continue;
s1.insert({a, b});
s2.insert({b, a});
int ai = s1.order_of_key(make_pair(a, b)), bi = s2.order_of_key(make_pair(b, a));
if(ai == bi){
if(ai <= cur) cur++;
}
else{
cur = min(cur, min(ai, bi));
}
}
lsi = i;
}
if(cur < s1.size()){
int a = s1.find_by_order(cur)->f, b = s2.find_by_order(cur)->f;
if(a > y && b > z) ans = max(ans, x+a+b);
}
}
cout << ans << "\n";
}
Compilation message (stderr)
# | 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... |