Submission #260768

#TimeUsernameProblemLanguageResultExecution timeMemory
260768ElyesChaabouniBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
/*#pragma GCC optimize("O3")*/ #include<bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> #define eps 1e-9 #define MOD1 998244353 #define MOD2 1000000007 #define INV_10 299473306 #define INF 1000000001 #define PI 3.14159265358979323846 using namespace std; long long delivery(int N, int K, int L, int p[]) { long long pr1[N+2], pr2[N+2], ans=0; pr1[0]=0; pr2[N+1]=0; for(int i = 1; i <= N; i++) pr1[i]=pr1[i-1]+p[i-1]; for(int i=N; i >= 1; i--) pr2[i]=pr2[i+1]+p[i-1]; int l=1, r=N; while(l <= r) { long long x=pr1[min(r, l+K-1)]-pr1[l-1], y=pr2[max(l, r-k+1)]-pr2[r+1]; if(x <= y) l=min(r, l+K-1)+1; else r=max(l, r-k+1)-1; ans+=min(min(2*x, 2*y), L); } return ans; } //size

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:24:59: error: 'k' was not declared in this scope
   long long x=pr1[min(r, l+K-1)]-pr1[l-1], y=pr2[max(l, r-k+1)]-pr2[r+1];
                                                           ^
boxes.cpp:29:28: error: no matching function for call to 'min(const long long int&, int&)'
   ans+=min(min(2*x, 2*y), L);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 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 boxes.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans+=min(min(2*x, 2*y), L);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 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 boxes.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   ans+=min(min(2*x, 2*y), L);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans+=min(min(2*x, 2*y), L);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   ans+=min(min(2*x, 2*y), L);
                            ^