Submission #544539

#TimeUsernameProblemLanguageResultExecution timeMemory
544539Jarif_RahmanTeam Contest (JOI22_team)C++17
100 / 100
415 ms20756 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indexed_set = tree<T,null_type,greater<T>,rb_tree_tag, tree_order_statistics_node_update>; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<tuple<int, int, int>> v(n); for(auto &[x, y, z]: v) cin >> x >> y >> z; sort(v.begin(), v.end()); indexed_set<pair<int, int>> s1, s2; int cur = 0; int lsi = 0, ls = -1; int ans = -1; for(int i = 0; i < n; i++){ auto [x, y, z] = v[i]; if(x > ls){ ls = x; for(int j = lsi; j < i; j++){ auto [ig, a, b] = v[j]; if(s1.find(make_pair(a, b)) != s1.end()) continue; s1.insert({a, b}); s2.insert({b, a}); int ai = s1.order_of_key(make_pair(a, b)), bi = s2.order_of_key(make_pair(b, a)); if(ai == bi){ if(ai <= cur) cur++; } else{ cur = min(cur, min(ai, bi)); } } lsi = i; } if(cur < s1.size()){ int a = s1.find_by_order(cur)->f, b = s2.find_by_order(cur)->f; if(a > y && b > z) ans = max(ans, x+a+b); } } cout << ans << "\n"; }

Compilation message (stderr)

team.cpp: In function 'int main()':
team.cpp:52:16: warning: comparison of integer expressions of different signedness: 'int' and '__gnu_pbds::detail::bin_search_tree_set<std::pair<int, int>, __gnu_pbds::null_type, std::greater<std::pair<int, int> >, __gnu_pbds::detail::tree_traits<std::pair<int, int>, __gnu_pbds::null_type, std::greater<std::pair<int, int> >, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         if(cur < s1.size()){
      |            ~~~~^~~~~~~~~~~
#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...