Language: C++

#include <iostream>
#include <vector>
using namespace std;
 
int N;
 
int main() {
    cin >> N;
    vector<long long> A(N + 1), B(N + 1);
    for (int i = 0; i < N + 1; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    B[N] = 0;
    int rest = 0;
    int ans = 0;
    for (int i = 0; i < N + 1; i++) {
        ans += min(rest, A[i]);
        A[i] -= min(rest, A[i]);
        ans += min(B[i], A[i]);
        rest = B[i] - min(B[i], A[i]);
    }
    cout << ans << endl;
}
 
#include <iostream>
#include <vector>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<long long> A(N + 1), B(N + 1);
    for (int i = 0; i < N + 1; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    B[N] = 0;
    long long rest = 0;
    long long ans = 0;
    for (int i = 0; i < N + 1; i++) {
        ans += min(rest, A[i]);
        A[i] -= min(rest, A[i]);
        ans += min(B[i], A[i]);
        rest = B[i] - min(B[i], A[i]);
    }
    cout << ans << endl;
}

提出情報


Compiler output:
a.cc: In function 'int main()':
a.cc:20:19: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   20 |         ans += min(rest, A[i]);
      |                ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:20:19: 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 |         ans += min(rest, A[i]);
      |                ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc:21:20: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   21 |         A[i] -= min(rest, A[i]);
      |                 ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:21:20: 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 |         A[i] -= min(rest, A[i]);
      |                 ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc: At global scope:
a.cc:32:5: error: redefinition of 'int N'
   32 | int N;
      |     ^
a.cc:5:5: note: 'int N' previously declared here
    5 | int N;
      |     ^
a.cc:34:5: error: redefinition of 'int main()'
   34 | int main() {
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main() {
      |     ^~~~
a.cc:55:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   55 | 提出情報
      | ^~~~~~~~