답안 #917811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917811 2024-01-28T20:03:49 Z _VIBE Team Contest (JOI22_team) C++17
0 / 100
1 ms 348 KB
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define endl '\n'

void Excuse_Me(int TC)
{
   int n;
   cin>>n;
   
   set<pair<int,int>> s[3];
   
   vector<vector<int>> g(n,vector<int>(3));
   
   vector<int> mx(3,0);
   
   priority_queue<pair<int,pair<int,int>>> pq;
   
   for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>g[i][j];
            pq.push({g[i][j],{i,j}});
            mx[j]=max(mx[j],g[i][j]);
        }
   }
   
   vector<int> ans(3,-1);
   
   int count=3;
   
   while(!pq.empty() and count){
        pair<int,pair<int,int>> p=pq.top();
        int val=p.first,i=p.second.first,j=p.second.second;
        pq.pop();
        
        if(ans[j]!=-1) continue;
        
        bool poss=true;
        
        for(int k=0;k<3;k++){
            if(k==j) continue;
            if(g[i][k]==mx[k]) poss=false;
        }
        
        if(poss){
          ans[j]=val;count--;  
        } 
        
   }
   
   if(count) cout<<-1;
   else{
        int x=0;
        for(auto e:ans) x+=e;
            cout<<x;
   }


   
   
   
   
    
}
 
signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    freopen("error.txt","w",stderr);
    int Tc=1;
    // cin>>Tc;
 
    for(int tc=1;tc<=Tc;tc++)
    {
        Excuse_Me(tc);
    }
   
    return 0;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:71:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |     freopen("error.txt","w",stderr);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -