Submission #133489

#TimeUsernameProblemLanguageResultExecution timeMemory
133489OrtSan (COCI17_san)C++11
Compilation error
0 ms0 KiB
#include<iostream> #include<vector> #include<algorithm> #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 j=indx;j<vp2.size();j++) s.insert(vp2[j].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 (stderr)

san.cpp: In function 'int main()':
san.cpp:46:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<vp1.size();i++) {
              ~^~~~~~~~~~~
san.cpp:49:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=indx;j<vp2.size();j++) s.insert(vp2[j].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:47: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:4:
/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:4:
/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:4:
/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:4:
/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:4:
/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:4:
/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/memory:81:0,
                 from /usr/include/c++/7/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:47,
                 from san.cpp:4:
/usr/include/c++/7/bits/shared_ptr.h:416:5: note: candidate: template<class _Tp> bool std::operator<(std::nullptr_t, const std::shared_ptr<_Tp>&)
     operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
     ^~~~~~~~
/usr/include/c++/7/bits/shared_ptr.h:416: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::shared_ptr<_Tp>'
       { return *__it < __val; }
                ~~~~~~^~~~~~~
In file included from /usr/include/c++/7/memory:81:0,
                 from /usr/include/c++/7/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:47,
                 from san.cpp:4:
/usr/include/c++/7/bits/shared_ptr.h:408:5: note: candidate: template<class _Tp> bool std::operator<(const std::shared_ptr<_Tp>&, std::nullptr_t)
     operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
     ^~~~~~~~
/usr/include/c++/7/bits/shared_ptr.h:408: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::shared_ptr<_Tp>'
       { return *__it < __val; }
                ~~~~~~^~~~~~~
In file included from /usr/include/c++/7/memory:81:0,
                 from /usr/include/c++/7/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:47,
                 from san.cpp:4:
/usr/include/c++/7/bits/shared_ptr.h:398:5: note: candidate: template<class _Tp, class _Up> bool std::operator<(const std::shared_ptr<_Tp>&, const std::shared_ptr<_Up>&)
     operator<(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
     ^~~~~~~~
/usr/include/c++/7/bits/shared_ptr.h:398: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::shared_ptr<_Tp>'
       { return *__it < __val; }
                ~~~~~~^~~~~~~
In file included from /usr/include/c++/7/bits/shared_ptr.h:52:0,
                 from /usr/include/c++/7/memory:81,
                 from /usr/include/c++/7/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:47,
                 from san.cpp:4:
/usr/include/c++/7/bits/shared_ptr_base.h:1460:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator<(std::nullptr_t, const std::__shared_ptr<_Tp, _Lp>&)
     operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
     ^~~~~~~~
/usr/include/c++/7/bits/shared_ptr_base.h:1460: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::__shared_ptr<_Tp, _Lp>'
       { return *__it < __val; }
                ~~~~~~^~~~~~~
In file included from /usr/include/c++/7/bits/shared_ptr.h:52:0,
                 from /usr/include/c++/7/memory:81,
                 from /usr/include/c++/7/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:47,
                 from san.cpp:4:
/usr/include/c++/7/bits/shared_ptr_base.h:1452:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator<(const std::__shared_ptr<_Tp, _Lp>&, std::nullptr_t)
     operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
     ^~~~~~~~
/usr/include/c++/7/bits/shared_ptr_base.h:1452: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::__shared_ptr<_Tp, _Lp>'
       { return *__it < __val; }
                ~~~~~~^~~~~~~
In file included from /usr/include/c++/7/bits/shared_ptr.h:52:0,
                 from /usr/include/c++/7/memory:81,
                 from /usr/include/c++/7/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/7/ext/pb_ds/assoc_container.hpp:47,
                 from san.cpp:4:
/usr/include/c++/7/bits/shared_ptr_base.h:1441:5: note: candidate: template<class _Tp, class _Up, __gnu_cxx::_Lock_policy _Lp> bool std::operator<(const std::__shared_ptr<_Tp1, _Lp>&, const std::__shared_ptr<_Tp2, _Lp>&)
     operator<(const __shared_ptr<_Tp, _Lp>& __a,
     ^~~~~~~~
/usr/include/c++/7/bits/shared_ptr_base.h:1441:5: note: