# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
133787 | 2019-07-21T11:05:54 Z | Ort | San (COCI17_san) | C++11 | 컴파일 오류 |
0 ms | 0 KB |
#include<bits/stdc++.h> #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; queue<ll> q; 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]; } } if(sum>=k) sol++; 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; vp2.erase(unique(vp2.begin(),vp2.end()),vp2.end() ); vp1.erase(unique(vp1.begin(),vp1.end()),vp1.end() ); for(int i=0;i<vp1.size();i++) { int indx = abs(distance((lower_bound(vp2.begin(),vp2.end(),make_pair(vp1[i].first,-inf))),vp2.begin())); // 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); q.push(vp2[j].second); } sol += (s.size()-s.order_of_key(k-vp1[i].second)); } else { int e = indx-indexp; while(e) { s.erase(s.find_by_order(s.order_of_key(q.front()))); e--; q.pop(); } sol += (s.size()-s.order_of_key(k-vp1[i].second)); } indexp = indx; } cout << sol; return 0; }
Compilation message
san.cpp: In function 'int main()': san.cpp:48:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0;i<vp1.size();i++) { ~^~~~~~~~~~~ san.cpp:52:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j=indx;j<vp2.size();j++) { ~^~~~~~~~~~~ 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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:49:90: 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:1429:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&) operator<(const sub_match<_Bi_iter>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/regex.h:1429: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::sub_match<_BiIter>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:1349:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&) operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/regex.h:1349: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::__cxx11::sub_match<_BiIter>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:1272:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*) operator<(const sub_match<_Bi_iter>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/regex.h:1272: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::sub_match<_BiIter>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:1198:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&) operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/regex.h:1198: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::__cxx11::sub_match<_BiIter>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:1121:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&) operator<(const sub_match<_Bi_iter>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/regex.h:1121: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::sub_match<_BiIter>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:1041:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&) operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/regex.h:1041: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/regex:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110, from san.cpp:1: /usr/include/c++/7/bits/regex.h:962:5: note: candidate: template<class _BiIter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&) operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) ^~~~~~~~ /usr/include/c++/7/bits/regex.h:962: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::sub_match<_BiIter>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/future:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:105, from san.cpp:1: /usr/include/c++/7/thread:281:3: note: candidate: bool std::operator<(std::thread::id, std::thread::id) operator<(thread::id __x, thread::id __y) noexcept ^~~~~~~~ /usr/include/c++/7/thread:281:3: note: no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'std::thread::id' In file included from /usr/include/c++/7/forward_list:38:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:104, from san.cpp:1: /usr/include/c++/7/bits/forward_list.h:1391:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<(const std::forward_list<_Tp, _Alloc>&, const std::forward_list<_Tp, _Alloc>&) operator<(const forward_list<_Tp, _Alloc>& __lx, ^~~~~~~~ /usr/include/c++/7/bits/forward_list.h:1391: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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::forward_list<_Tp, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from san.cpp:1: /usr/include/c++/7/valarray:1186:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::result_type> std::operator<(const _Tp&, const std::valarray<_Tp>&) _DEFINE_BINARY_OPERATOR(<, __less) ^ /usr/include/c++/7/valarray:1186:1: 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::valarray<_Tp>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from san.cpp:1: /usr/include/c++/7/valarray:1186:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::result_type> std::operator<(const std::valarray<_Tp>&, const _Tp&) _DEFINE_BINARY_OPERATOR(<, __less) ^ /usr/include/c++/7/valarray:1186:1: 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/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, 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::valarray<_Tp>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from san.cpp:1: /usr/include/c++/7/valarray:1186:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_Val