Submission #617432

#TimeUsernameProblemLanguageResultExecution timeMemory
617432patrikpavic2Team Contest (JOI22_team)C++17
100 / 100
530 ms21280 KiB
#include <cstdio> #include <cstring> #include <algorithm> #include <set> #include <vector> #define X first #define Y second #define PB push_back using namespace std; typedef pair < int, int > pii; const int N = 2e5 + 500; int n, x[N], y[N], z[N], izb[N]; vector < int > v; set < pii > Sx, Sy; bool cmp(int A, int B){ if(z[A] == z[B]){ if(x[A] == x[B]) return y[A] < y[B]; return x[A] < x[B]; } return z[A] > z[B]; } void izbaci(int k){ if(izb[k]) return; izb[k] = 1; Sx.erase({x[k], k}); Sy.erase({y[k], k}); } int probaj_tri(int xx, int yy, int zz){ if(x[xx] <= x[yy] || x[xx] <= x[zz]) return -1; if(y[yy] <= y[xx] || y[yy] <= y[zz]) return -1; if(z[zz] <= z[xx] || z[zz] <= z[yy]) return -1; return x[xx] + y[yy] + z[zz]; } int main(){ scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%d%d%d", x + i, y + i, z + i); v.PB(i); Sx.insert({x[i], i}); Sy.insert({y[i], i}); } sort(v.begin(), v.end(), cmp); int ans = -1; for(int i = 0;i < n;){ int j = i; while(j < n && z[v[j]] == z[v[i]]) j++; for(int k = i;k < j;k++) izbaci(v[k]); while((int)Sx.size() > 0){ int mx = Sx.rbegin() -> Y, my = Sy.rbegin() -> Y; if(y[mx] == y[my]) izbaci(mx); else if(x[mx] == x[my]) izbaci(my); else break; } if((int)Sx.size() > 0){ int mx = Sx.rbegin() -> Y, my = Sy.rbegin() -> Y; for(int k = i;k < j;k++) ans = max(ans, probaj_tri(mx, my , v[k])); } i = j; } printf("%d\n", ans); return 0; }

Compilation message (stderr)

team.cpp: In function 'int main()':
team.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
team.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d%d%d", x + i, y + i, z + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...