# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
918597 | manishjha91 | Team Contest (JOI22_team) | C++17 | 290 ms | 16556 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>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
const int inf = 1e9;
// #ifndef ONLINE_JUDGE
// #include "E:\Personal\cpp_codes\debugalgo.h"
// #else
// #define debug(x)
// #endif
void solve()
{
int n;
cin >> n;
vector<array<int,3>> a(n);
int mxx = 0, mxy = 0, mxz = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i][0]>>a[i][1]>>a[i][2];
}
priority_queue<pair<int,int>> pq[3];
set<int> banned;
for(int i=0; i<n; i++)
{
for(int j=0; j<3; j++)
{
pq[j].push({a[i][j],i});
}
}
int ans = -1;
while(!pq[0].empty() && !pq[1].empty() && !pq[1].empty())
{
for(int j=0; j<3; j++)
{
while(!pq[j].empty() && banned.count(pq[j].top().second))
{
pq[j].pop();
}
}
if(pq[0].empty() || pq[1].empty() || pq[1].empty()) break;
int mxx = pq[0].top().first;
int mxy = pq[1].top().first;
int mxz = pq[2].top().first;
if(a[pq[0].top().second][1]>=mxy || a[pq[0].top().second][2]>=mxz)
{
banned.insert(pq[0].top().second);
continue;
}
if(a[pq[1].top().second][2]>=mxz || a[pq[1].top().second][0]>=mxx)
{
banned.insert(pq[1].top().second);
continue;
}
if(a[pq[2].top().second][1]>=mxy || a[pq[2].top().second][0]>=mxx)
{
banned.insert(pq[2].top().second);
continue;
}
ans = max(ans,mxx + mxy + mxz);
break;
}
cout<<ans<<"\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("error.txt", "w", stderr);
// #endif
int tt = 1;
// cin >> tt;
while (tt--)
{
solve();
}
}
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... |