제출 #975064

#제출 시각아이디문제언어결과실행 시간메모리
975064pransh_8사탕 분배 (IOI21_candies)C++17
컴파일 에러
0 ms0 KiB
//pransh_8 #include "candies.h" #include <bits/stdc++.h> using namespace std; //Macros: #define FOR(i, a, n) for(int i=a;i<n;++i) #define FORR(i, a, n) for(int i=a;i>=n;--i) /*------------------------------Code-Begins----------------------------------*/ vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(), q = l.size(); vector<int> ans(n); FOR(i,0,q) { FOR(k,l[i]-1,r[i]) { if (v[i]>0) ans[k]=min(c[k],ans[k]+v[i]); else ans[k]=max(0ll,ans[k]+v[i]); } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:21:43: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   21 |                 ans[k]=max(0ll,ans[k]+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: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:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   21 |                 ans[k]=max(0ll,ans[k]+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: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:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   21 |                 ans[k]=max(0ll,ans[k]+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: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:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |                 ans[k]=max(0ll,ans[k]+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: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:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |                 ans[k]=max(0ll,ans[k]+v[i]);
      |                                           ^