# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133486 | 2019-07-20T22:46:18 Z | Ort | San (COCI17_san) | C++17 | Compilation error |
0 ms | 0 KB |
#include<iostream> #include<vector> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<functional> #define ll long long #define MAX 42 #define inf 1000000000000000000 using namespace __gnu_pbds; using namespace std; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; ll n, k, sol; ll c[MAX], h[MAX]; vector<pair<ll,ll> > vp1, vp2; indexed_set s; int main() { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); cin >> n >> k; for(int i=0;i<n;i++) cin >> h[i] >> c[i]; int a = n>>1; int b = n-a; for(int i=0;i<(1<<a);i++) { ll sum = 0; ll max = 0; for(int j=0;j<a;j++) if((i>>j)&1 && h[j]>=max) { max = h[j]; sum += c[j]; } vp1.push_back(make_pair(max,sum)); } for(int i=0;i<(1<<b);i++) { ll sum = 0; ll max = 0; for(int j=0;j<b;j++) if((i>>j)&1 && h[j+a]>=max) { max = h[j+a]; sum += c[j+a]; } vp2.push_back(make_pair(max,sum)); } sort(vp2.begin(),vp2.end()); sort(vp1.begin(),vp1.end()); int indexp = -1; for(int i=0;i<vp1.size();i++) { int indx = lower_bound(vp2.begin(),vp2.end(),make_pair(vp1[i].first,-inf)) - vp2.begin(); if(indexp==-1) { for(int i=indx;i<vp2.size();i++) s.insert(vp2[i].second); sol += (s.size()-s.order_of_key(k-vp1[i].second+1)); } else { int e = abs(indexp-indx); while(e--) { s.erase(s.find_by_order(0)); } sol += (s.size()-s.order_of_key(k-vp1[i].second+1)); } indexp = indx; } cout << sol; return 0; }
Compilation message
san.cpp: In function 'int main()': san.cpp:45:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0;i<vp1.size();i++) { ~^~~~~~~~~~~ san.cpp:48:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=indx;i<vp2.size();i++) s.insert(vp2[i].second); ~^~~~~~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Value = const std::pair<long long int, long int>]': /usr/include/c++/7/bits/stl_algobase.h:959:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Tp = std::pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' /usr/include/c++/7/bits/stl_algobase.h:993:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Tp = std::pair<long long int, long int>]' san.cpp:46:76: required from here /usr/include/c++/7/bits/predefined_ops.h:65:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:888:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&) operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:888:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:895:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&) operator<(const __normal_iterator<_Iterator, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:895:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/list:63:0, from /usr/include/c++/7/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp:46, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:73, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/bits/stl_list.h:1918:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<(const std::__cxx11::list<_Tp, _Alloc>&, const std::__cxx11::list<_Tp, _Alloc>&) operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_list.h:1918:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::list<_Tp, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/set:62:0, from /usr/include/c++/7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp:42, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:70, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/bits/stl_multiset.h:913:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&) operator<(const multiset<_Key, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_multiset.h:913:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::multiset<_Key, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/set:61:0, from /usr/include/c++/7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp:42, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:70, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/bits/stl_set.h:930:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&) operator<(const set<_Key, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_set.h:930:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::set<_Key, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/map:62:0, from /usr/include/c++/7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp:41, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:70, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/bits/stl_multimap.h:1078:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&) operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_multimap.h:1078:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::multimap<_Key, _Tp, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/map:61:0, from /usr/include/c++/7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp:41, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:70, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/bits/stl_map.h:1412:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&) operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_map.h:1412:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::map<_Key, _Tp, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/map:60:0, from /usr/include/c++/7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp:41, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:70, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/bits/stl_tree.h:1543:5: note: candidate: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&) operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_tree.h:1543:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/node_handle.h:39:0, from /usr/include/c++/7/bits/hashtable.h:37, from /usr/include/c++/7/unordered_map:47, from /usr/include/c++/7/functional:60, from /usr/include/c++/7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp:45, from /usr/include/c++/7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:43, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:67, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/optional:934:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Up>() < declval<_Tp>()))> std::operator<(const _Up&, const std::optional<_Tp>&) operator<(const _Up& __lhs, const optional<_Tp>& __rhs) ^~~~~~~~ /usr/include/c++/7/optional:934:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::optional<_Tp>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/node_handle.h:39:0, from /usr/include/c++/7/bits/hashtable.h:37, from /usr/include/c++/7/unordered_map:47, from /usr/include/c++/7/functional:60, from /usr/include/c++/7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp:45, from /usr/include/c++/7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:43, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:67, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/optional:928:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() < declval<_Up>()))> std::operator<(const std::optional<_Tp>&, const _Up&) operator<(const optional<_Tp>& __lhs, const _Up& __rhs) ^~~~~~~~ /usr/include/c++/7/optional:928:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::optional<_Tp>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/node_handle.h:39:0, from /usr/include/c++/7/bits/hashtable.h:37, from /usr/include/c++/7/unordered_map:47, from /usr/include/c++/7/functional:60, from /usr/include/c++/7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp:45, from /usr/include/c++/7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:43, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:67, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/optional:868:5: note: candidate: template<class _Tp> constexpr bool std::operator<(std::nullopt_t, const std::optional<_Tp>&) operator<(nullopt_t, const optional<_Tp>& __rhs) noexcept ^~~~~~~~ /usr/include/c++/7/optional:868:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::optional<_Tp>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/node_handle.h:39:0, from /usr/include/c++/7/bits/hashtable.h:37, from /usr/include/c++/7/unordered_map:47, from /usr/include/c++/7/functional:60, from /usr/include/c++/7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp:45, from /usr/include/c++/7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:43, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:67, from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:48, from san.cpp:3: /usr/include/c++/7/optional:863:5: note: candidate: template<class _Tp> constexpr bool std::operator<(const std::optional<_Tp>&, std::nullopt_t) operator<(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept ^~~~~~~~ /usr/include/c++/7/optional:863:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from san.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::optional<_Tp>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/node_handle.h:39:0, from /usr/include/c++/7/bits/hashtable.h:37, from /usr/include/c++/7/unordered_map:47, from /usr/include/c++/7/functional:60, from /usr/include/c++/7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp:45, from /usr/include/c++/7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:43, from /usr/include/c++/7/ext/pb_ds/detail/container_base_dispatch.hpp:67,