# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
380245 | vishesh312 | Vudu (COCI15_vudu) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
const int mod = 1e9+7;
void solve(int tc) {
int n;
cin >> n;
vector<pair<int, int>> v(n+1);
for (int i = 1; i <= n; ++i) {
cin >> v[i].first;
v[i].second = i;
}
vector<int> a(n+1);
sort(all(v));
ll cur = 0;
for (int i = 0; i <= n; ++i) {
if (i) if (v[i].first == v[i-1].first) --cur;
a[v[i].second] = cur;
++cur;
}
ll p;
cin >> p;
ll ans = 0;
ordered_set s;
s.insert(-1);
for (int i = 1; i <= n; ++i) {
a[i] += a[i-1]-p;
ans += s.order_of_key(a[i]);
s.insert(a[i]-1);
}
cout << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) solve(i);
return 0;
}
Compilation message (stderr)
In file included from /usr/include/c++/9/ext/pb_ds/detail/type_utils.hpp:47, from /usr/include/c++/9/ext/pb_ds/tag_and_trait.hpp:46, from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:46, from vudu.cpp:7: /usr/include/c++/9/tr1/type_traits:121:3: error: redefinition of 'struct std::tr1::__is_integral_helper<long long int>' 121 | _DEFINE_SPEC(0, __is_integral_helper, long long, true) | ^~~~~~~~~~~~ /usr/include/c++/9/tr1/type_traits:117:3: note: previous definition of 'struct std::tr1::__is_integral_helper<long long int>' 117 | _DEFINE_SPEC(0, __is_integral_helper, int, true) | ^~~~~~~~~~~~ /usr/include/c++/9/tr1/type_traits:549:3: error: redefinition of 'struct std::tr1::__is_signed_helper<long long int>' 549 | _DEFINE_SPEC(0, __is_signed_helper, long long, true) | ^~~~~~~~~~~~ /usr/include/c++/9/tr1/type_traits:547:3: note: previous definition of 'struct std::tr1::__is_signed_helper<long long int>' 547 | _DEFINE_SPEC(0, __is_signed_helper, int, true) | ^~~~~~~~~~~~ In file included from /usr/include/c++/9/tr1/functional:42, from /usr/include/c++/9/ext/pb_ds/detail/standard_policies.hpp:51, from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:47, from vudu.cpp:7: /usr/include/c++/9/tr1/functional_hash.h:75:3: error: redefinition of 'std::size_t std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long long int; std::size_t = long unsigned int]' 75 | _TR1_hashtable_define_trivial_hash(long long); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/9/tr1/functional_hash.h:73:3: note: 'std::size_t std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long long int; std::size_t = long unsigned int]' previously declared here 73 | _TR1_hashtable_define_trivial_hash(int); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/9/tr1/functional_hash.h:77:3: error: expected ',' or '...' before '__val' 77 | _TR1_hashtable_define_trivial_hash(unsigned int); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/9/tr1/functional_hash.h:77:3: error: template-id 'operator()<>' for 'std::size_t std::tr1::hash<long unsigned int>::operator()(unsigned int) const' does not match any template declaration 77 | _TR1_hashtable_define_trivial_hash(unsigned int); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/9/tr1/functional_hash.h:77:3: note: saw 1 'template<>', need 2 for specializing a member function template 77 | _TR1_hashtable_define_trivial_hash(unsigned int); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/9/algorithm:71, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from vudu.cpp:1: /usr/include/c++/9/functional:199:16: error: template parameter 'int _Num' 199 | template<int _Num> struct _Placeholder { }; | ^~~~ In file included from /usr/include/c++/9/ext/pb_ds/detail/standard_policies.hpp:51, from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:47, from vudu.cpp:7: /usr/include/c++/9/tr1/functional:53:24: error: redeclared here as 'long long int <anonymous>' 53 | template<int> struct _Placeholder; | ^~~~~~~~~~~~ In file included from /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/traits.hpp:44, from /usr/include/c++/9/ext/pb_ds/detail/branch_policy/traits.hpp:45, from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:49, from vudu.cpp:7: /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp: In instantiation of 'class __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >': /usr/include/c++/9/bits/stl_iterator_base_types.h:162:12: recursively required by substitution of 'template<class _Iterator> struct std::__iterator_traits<_Iterator, std::__void_t<typename _Iterator::iterator_category, typename _Iterator::value_type, typename _Iterator::difference_type, typename _Iterator::pointer, typename _Iterator::reference> > [with _Iterator = __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >]' /usr/include/c++/9/bits/stl_iterator_base_types.h:162:12: required from 'struct std::iterator_traits<__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> > >' /usr/include/c++/9/ext/pb_ds/detail/branch_policy/branch_policy.hpp:92:68: required from 'struct __gnu_pbds::detail::branch_policy<__gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, std::allocator<char> >, std::allocator<char> >' /usr/include/c++/9/ext/pb_ds/tree_policy.hpp:64:9: required from 'class __gnu_pbds::tree_order_statistics_node_update<__gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, std::allocator<char> >, std::less_equal<long long int>, std::allocator<char> >' /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:99:11: required from 'class __gnu_pbds::detail::bin_search_tree_set<long long int, __gnu_pbds::null_type, std::less_equal<long long int>, __gnu_pbds::detail::tree_traits<long long int, __gnu_pbds::null_type, std::less_equal<long long int>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >' /usr/include/c++/9/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp:84:11: required from 'class __gnu_pbds::detail::rb_tree_set<long long int, __gnu_pbds::null_type, std::less_equal<long long int>, __gnu_pbds::detail::tree_traits<long long int, __gnu_pbds::null_type, std::less_equal<long long int>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >' /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:555:9: required from 'class __gnu_pbds::basic_branch<long long int, __gnu_pbds::null_type, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update<__gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, std::allocator<char> >, std::less_equal<long long int>, std::allocator<char> >, __gnu_cxx::typelist::node<__gnu_cxx::typelist::chain<std::less_equal<long long int>, __gnu_cxx::typelist::chain<__gnu_pbds::detail::tree_traits<long long int, __gnu_pbds::null_type, std::less_equal<long long int>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, __gnu_cxx::typelist::null_type> > >, std::allocator<char> >' /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:635:9: required from 'class __gnu_pbds::tree<long long int, __gnu_pbds::null_type, std::less_equal<long long int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>' vudu.cpp:35:17: required from here /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp:181:7: error: postfix '__gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc> __gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc>::operator++(ll) [with Node_Pointer = __gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*; Value_Type = long long int; Pointer = long long int*; Const_Pointer = const long long int*; Reference = long long int&; Const_Reference = const long long int&; bool Is_Forward_Iterator = true; _Alloc = std::allocator<char>; ll = long long int]' must have 'int' as its argument 181 | operator++(int) | ^~~~~~~~ /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp:196:7: error: postfix '__gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc> __gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc>::operator--(ll) [with Node_Pointer = __gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*; Value_Type = long long int; Pointer = long long int*; Const_Pointer = const long long int*; Reference = long long int&; Const_Reference = const long long int&; bool Is_Forward_Iterator = true; _Alloc = std::allocator<char>; ll = long long int]' must have 'int' as its argument 196 | operator--(int) | ^~~~~~~~ /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp: In instantiation of 'class __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, false, std::allocator<char> >': /usr/include/c++/9/type_traits:1017:12: required from 'struct std::is_assignable<__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >&, const __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >&>' /usr/include/c++/9/type_traits:1029:12: required from 'struct std::__is_copy_assignable_impl<__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, true>' /usr/include/c++/9/type_traits:1035:12: required from 'struct std::is_copy_assignable<__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> > >' /usr/include/c++/9/type_traits:131:12: required from 'struct std::__and_<std::is_copy_assignable<__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> > >, std::is_copy_assignable<bool> >' /usr/include/c++/9/bits/stl_pair.h:378:7: required from 'struct std::pair<__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*, long long int, long long int*, const long long int*, long long int&, const long long int&, true, std::allocator<char> >, bool>' vudu.cpp:36:16: required from here /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp:181:7: error: postfix '__gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc> __gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc>::operator++(ll) [with Node_Pointer = __gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*; Value_Type = long long int; Pointer = long long int*; Const_Pointer = const long long int*; Reference = long long int&; Const_Reference = const long long int&; bool Is_Forward_Iterator = false; _Alloc = std::allocator<char>; ll = long long int]' must have 'int' as its argument 181 | operator++(int) | ^~~~~~~~ /usr/include/c++/9/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp:196:7: error: postfix '__gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc> __gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc>::operator--(ll) [with Node_Pointer = __gnu_pbds::detail::rb_tree_node_<long long int, long unsigned int, std::allocator<char> >*; Value_Type = long long int; Pointer = long long int*; Const_Pointer = const long long int*; Reference = long long int&; Const_Reference = const long long int&; bool Is_Forward_Iterator = false; _Alloc = std::allocator<char>; ll = long long int]' must have 'int' as its argument 196 | operator--(int) | ^~~~~~~~