이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int X[150005];
int Y[150005];
int Z[150005];
set<pair<int,int> > Xv, Yv, Zv;
void remv(int x){
Xv.erase(Xv.lower_bound({X[x],x}));
Yv.erase(Yv.lower_bound({Y[x],x}));
Zv.erase(Zv.lower_bound({Z[x],x}));
}
void getTop(int&a, int&b, int&c){
if (Xv.size()<3){
a = -1; b = -1; c = -1;
return;
}
a = (*--Xv.end()).second;
b = (*--Yv.end()).second;
c = (*--Zv.end()).second;
}
bool checkTop(int a, int b, int c){
if (a==b && b==c){
remv(a);
return false;
}
if (a==b){
remv(a);
return false;
}
else if (b==c){
remv(b);
return false;
}
else if (a==c){
remv(a);
return false;
}
if (Y[a]>=Y[b] || Z[a]>=Z[c]){
remv(a);
return false;
}
if (X[b]>=X[a] || Z[b]>=Z[c]){
remv(b);
return false;
}
if (X[c]>=X[a] || Y[c]>=Y[b]){
remv(c);
return false;
}
return true;
}
int main(){
int n;
scanf("%d",&n);
for (int x = 0; x<n; x++){
scanf("%d%d%d",&X[x],&Y[x],&Z[x]);
}
for (int x = 0; x<n; x++){
Xv.insert({X[x],x});
Yv.insert({Y[x],x});
Zv.insert({Z[x],x});
}
int a,b,c;
while (true){
getTop(a,b,c);
if (a==-1){
printf("-1");
return 0;
}
if (checkTop(a,b,c)){
printf("%d",X[a]+Y[b]+Z[c]);
return 0;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
team.cpp: In function 'int main()':
team.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
team.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
61 | scanf("%d%d%d",&X[x],&Y[x],&Z[x]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |