이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long int ll;
ll n,z,t,i,j,x,y,a[1100000];
pair<ll,pair<ll,ll>> p[1100000];
map<pair<ll,pair<ll,ll>>,ll> m;
vector<pair<ll,ll>> u;
vector<pair<pair<ll,ll>,ll>> v[1100000];
set<pair<pair<ll,ll>,ll>> s;
int main()
{
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
scanf("%lld %lld %lld",&x,&y,&z);
if(m[{x,{y,z}}]==1)
continue;
m[{x,{y,z}}]=1;
t++;
p[t]={x,{y,z}};
}
z=0;
n=t;
sort(p+1,p+n+1);
for(i=1;i<=n;i++)
{
s.insert({p[i].second,i});
for(auto l=s.begin();l!=s.end();l++)
v[i+1].push_back((*l));
}
for(i=1;i<=n;i++)
{//printf("%lld",i);
t=0;
u.clear();
for(j=0;j<(i-1);j++)
{
if(p[v[i][j].second].first==p[i].first)
continue;
if(v[i][j].first.first>p[i].second.first||v[i][j].first.second>p[i].second.second)
{u.push_back(v[i][j].first); t++; }
}
for(j=0;j<t;j++)
{
if(j==0)
a[j]=u[j].second;
else
a[j]=max(a[j-1],u[j].second);
}
for(j=t-1;j>=1;j--)
{
if(u[j].second<a[j-1])
{
z=max(z,u[j].first+a[j-1]+p[i].first);
break;
}
}
}
if(z==0)
z=-1;
printf("%lld",z);
}
컴파일 시 표준 에러 (stderr) 메시지
team.cpp: In function 'int main()':
team.cpp:19:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
19 | if(m[{x,{y,z}}]==1)
| ^~
team.cpp:21:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
21 | m[{x,{y,z}}]=1;
| ^
team.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
team.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%lld %lld %lld",&x,&y,&z);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |