Submission #713835

#TimeUsernameProblemLanguageResultExecution timeMemory
713835scottchouTeam Contest (JOI22_team)C++17
37 / 100
2091 ms4456 KiB
#include<bits/stdc++.h> using namespace std; int const N = 150005; struct Person{ int x, y, z; }a[N]; bool cmp(Person x, Person y){ return x.x < y.x; } bool cmp2(Person x, Person y){ return x.y < y.y; } int main(){ int n; cin >> n; vector<int> xsort, ysort, zsort; for(int i = 0; i < n; i++){ cin >> a[i].x >> a[i].y >> a[i].z; xsort.push_back(a[i].x); ysort.push_back(a[i].y); zsort.push_back(a[i].z); } sort(a, a + n, cmp); sort(xsort.begin(), xsort.end()); sort(ysort.begin(), ysort.end()); sort(ysort.begin(), ysort.end()); xsort.resize(unique(xsort.begin(), xsort.end()) - xsort.begin()); ysort.resize(unique(ysort.begin(), ysort.end()) - ysort.begin()); zsort.resize(unique(zsort.begin(), zsort.end()) - zsort.begin()); vector<Person> p; int last = 0, ans = 0; for(int i = 0; i < n; i++){ if(a[i].x != a[i - 1].x){ for(; last < i; last++){ p.push_back(a[last]); } sort(p.begin(), p.end(), cmp2); } if(p.empty()) continue; int maxz = 0; vector<int> prez(p.size()); prez[0] = 0; int lastt = 0; for(int j = 1; j < p.size(); j++){ prez[j] = prez[j - 1]; if(p[j].y != p[j - 1].y){ for(; lastt < j; lastt++){ prez[j] = max(prez[j], p[lastt].z); } } } for(int j = p.size() - 1; j >= 0 && p[j].y > a[i].y; j--){ if(p[j].z < prez[j] && a[i].z < prez[j]){ ans = max(ans, prez[j] + p[j].y + a[i].x); } } } if(!ans){ cout << -1 << '\n'; }else cout << ans << '\n'; }

Compilation message (stderr)

team.cpp: In function 'int main()':
team.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Person>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int j = 1; j < p.size(); j++){
      |                        ~~^~~~~~~~~~
team.cpp:41:13: warning: unused variable 'maxz' [-Wunused-variable]
   41 |         int maxz = 0;
      |             ^~~~
#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...