# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894868 | 2023-12-29T06:44:36 Z | Sir_Ahmed_Imran | Distributing Candies (IOI21_candies) | C++17 | Compilation error |
0 ms | 0 KB |
///~~~LOTA~~~/// #include "candies.h" #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define N 300001 vector<int> distribute_candies(vector<int> c,vector<int> l,vector<int> r,vector<int> v){ ll o=0; vector<ll> x,y; for(int i=0;i<c.size();i++) y.append(0); for(int i=0;i<l.size();i++){ for(int j=l[i];j<=r[i];j++){ if(v[i]>0) o+=min(v[i],c[j]-y[j]); else o+=max(v[i],-y[j]); y[j]=max(0,min(c[j],y[j]+v[i])); } x.append(o); } }
Compilation message
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)': candies.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 16 | for(int i=0;i<c.size();i++) | ~^~~~~~~~~ candies.cpp:18:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 18 | for(int i=0;i<l.size();i++){ | ~^~~~~~~~~ candies.cpp:20:45: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 20 | if(v[i]>0) o+=min(v[i],c[j]-y[j]); | ^ In file included from /usr/include/c++/10/vector:60, from candies.h:1, from candies.cpp:2: /usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: candies.cpp:20:45: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 20 | if(v[i]>0) o+=min(v[i],c[j]-y[j]); | ^ In file included from /usr/include/c++/10/vector:60, from candies.h:1, from candies.cpp:2: /usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 278 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:278:5: note: template argument deduction/substitution failed: candies.cpp:20:45: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 20 | if(v[i]>0) o+=min(v[i],c[j]-y[j]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from candies.cpp:3: /usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)' 3468 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: candies.cpp:20:45: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 20 | if(v[i]>0) o+=min(v[i],c[j]-y[j]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from candies.cpp:3: /usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)' 3474 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3474:5: note: template argument deduction/substitution failed: candies.cpp:20:45: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 20 | if(v[i]>0) o+=min(v[i],c[j]-y[j]); | ^ candies.cpp:21:35: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 21 | else o+=max(v[i],-y[j]); | ^ In file included from /usr/include/c++/10/vector:60, from candies.h:1, from candies.cpp:2: /usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: candies.cpp:21:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 21 | else o+=max(v[i],-y[j]); | ^ In file included from /usr/include/c++/10/vector:60, from candies.h:1, from candies.cpp:2: /usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: candies.cpp:21:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 21 | else o+=max(v[i],-y[j]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from candies.cpp:3: /usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3480 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3480:5: note: template argument deduction/substitution failed: candies.cpp:21:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 21 | else o+=max(v[i],-y[j]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from candies.cpp:3: /usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3486 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3486:5: note: template argument deduction/substitution failed: candies.cpp:21:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 21 | else o+=max(v[i],-y[j]); | ^ candies.cpp:22:42: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 22 | y[j]=max(0,min(c[j],y[j]+v[i])); | ^ In file included from /usr/include/c++/10/vector:60, from candies.h:1, from candies.cpp:2: /usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: candies.cpp:22:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 22 | y[j]=max(0,min(c[j],y[j]+v[i])); | ^ In file included from /usr/include/c++/10/vector:60, from candies.h:1, from candies.cpp:2: /usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 278 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:278:5: note: template argument deduction/substitution failed: candies.cpp:22:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 22 | y[j]=max(0,min(c[j],y[j]+v[i])); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from candies.cpp:3: /usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)' 3468 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: candies.cpp:22:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 22 | y[j]=max(0,min(c[j],y[j]+v[i])); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from candies.cpp:3: /usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)' 3474 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3474:5: note: template argument deduction/substitution failed: candies.cpp:22:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 22 | y[j]=max(0,min(c[j],y[j]+v[i])); | ^ candies.cpp:26:1: warning: no return statement in function returning non-void [-Wreturn-type] 26 | } | ^