답안 #550386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550386 2022-04-18T02:03:07 Z Stjarna Team Contest (JOI22_team) C++14
0 / 100
1 ms 308 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define X first
#define Y second
int n,x[150005][5],ot[150005],a,b,c,ans=-1,fr[150005];
multiset<int>ss[5];
priority_queue<pair<int,pair<int,int> > >pq;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d %d %d",&x[i][0],&x[i][1],&x[i][2]);
        pq.push({x[i][0]-x[i][2],{0,i}});
        pq.push({x[i][1]-x[i][0],{1,i}});
        pq.push({x[i][2]-x[i][1],{2,i}});
    }
    while(!pq.empty()){
        a=pq.top().X;
        b=pq.top().Y.X;
        c=pq.top().Y.Y;
        pq.pop();
        ot[c]++;
        if(ot[c]==1){
            fr[c]=b;
            ss[b].insert(x[c][b]);
        }
        else if(ot[c]==2){
            ss[fr[c]].erase(ss[fr[c]].find(x[c][fr[c]]));
        }
        if(!pq.empty()){
            if(a!=pq.top().X){
                if((!ss[0].empty())&&(!ss[1].empty())&&(!ss[2].empty())){
                    ans=max(ans,*ss[0].begin()+*ss[1].begin()+*ss[2].begin());
                }
            }
        }
    }
    printf("%d",ans);
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
team.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d %d %d",&x[i][0],&x[i][1],&x[i][2]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -