# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
917794 | 2024-01-28T19:36:12 Z | _VIBE | Team Contest (JOI22_team) | C++17 | 1 ms | 448 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)); for(int i=0;i<n;i++){ for(int j=0;j<3;j++){ int x; cin>>x; s[j].insert({x,i}); g[i][j]=x; } } bool ok=true; while(ok){ ok=false; for(int i=0;i<3;i++){ if(s[i].empty()) break; } for(int i=0;i<3;i++){ pair<int,int> p=*s[i].rbegin(); for(int j=0;j<3;j++){ if(i==j) continue; pair<int,int> q=*s[j].rbegin(); if(g[p.second][j]==q.first){ ok=true; s[j].erase(s[j].find(q)); } } if(ok){ s[i].erase(s[i].find(p));break; } } } bool poss=true; int ans=0; for(int i=0;i<3;i++){ if(s[i].empty()) poss=false; else ans+=(*s[i].rbegin()).first; } if(!poss) cout<<-1; else cout<<ans; } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Runtime error | 1 ms | 448 KB | Execution killed with signal 11 |
4 | 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 | Runtime error | 1 ms | 448 KB | Execution killed with signal 11 |
4 | 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 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
4 | 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 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
4 | 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 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
4 | 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 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
4 | 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 | Runtime error | 1 ms | 448 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |