Submission #547760

#TimeUsernameProblemLanguageResultExecution timeMemory
547760PherokungTeam Contest (JOI22_team)C++14
100 / 100
102 ms5652 KiB
#include<bits/stdc++.h> using namespace std; #define F first #define S second typedef pair<int,int> pa; int n,X[3][150005]; pa v[3][150005]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) for(int j=0;j<=2;j++){ scanf("%d",&X[j][i]); v[j][i] = {X[j][i],i}; } for(int i=0;i<=2;i++) sort(v[i]+1, v[i]+n+1, greater<pa>()); int a = 1, b = 1, c = 1; while(a <= n && b <= n && c <= n){ int pa = v[0][a].S, pb = v[1][b].S, pc = v[2][c].S; if(X[1][pa] >= X[1][pb] || X[2][pa] >= X[2][pc]) { a++; continue; } if(X[0][pb] >= X[0][pa] || X[2][pb] >= X[2][pc]){ b++; continue; } if(X[0][pc] >= X[0][pa] || X[1][pc] >= X[1][pb]){ c++; continue; } break; } if(a <= n && b <= n && c <=n) printf("%d",v[0][a].F + v[1][b].F + v[2][c].F); else printf("-1"); }

Compilation message (stderr)

team.cpp: In function 'int main()':
team.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
team.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |    scanf("%d",&X[j][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...