Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int battle(uint32_t &monster, uint32_r &yu_sya)
{
    int win = min(monster, yu_sya);
    
    monster -= win;
    yu_sya -= win;
    
    return win;
}

int main(int argc, const char * argv[])
{
    uint32_t N;
    cin >> N;
    
    vector<uint32_t> A;
    for (uint32_t i = 0; i < N+1; i++) {
        uint32_t tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    
    vector<uint32_t> B;
    for (uint32_t i = 0; i < N; i++) {
        uint32_t tmp;
        cin >> tmp;
        B.push_back(tmp);
    }
    
    uint32_t win = 0;
    uint32_t nokori_yu_sya = 0;
    for (uint32_t i = 0; i < N + 1; i++) {
        uint32_t monster = A[i];
        uint32_t yu_sya;
        if (i == N) {
            yu_sya = 0;
        }else {
            yu_sya = B[i];
        }
        
        if (nokori_yu_sya > 0) {
            win += battle(monster, nokori_yu_sya);
        }
        win += battle(monster, yu_sya);
        
        nokori_yu_sya = yu_sya;
    }
    
    cout << win << endl;
    
    return 0;
}


Compiler output:
a.cc:6:12: error: 'uint32_t' was not declared in this scope
    6 | int battle(uint32_t &monster, uint32_r &yu_sya)
      |            ^~~~~~~~
a.cc:4:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    3 | #include <algorithm>
  +++ |+#include <cstdint>
    4 | using namespace std;
a.cc:6:22: error: 'monster' was not declared in this scope; did you mean 'const'?
    6 | int battle(uint32_t &monster, uint32_r &yu_sya)
      |                      ^~~~~~~
      |                      const
a.cc:6:31: error: 'uint32_r' was not declared in this scope; did you mean 'u_int32_t'?
    6 | int battle(uint32_t &monster, uint32_r &yu_sya)
      |                               ^~~~~~~~
      |                               u_int32_t
a.cc:6:41: error: 'yu_sya' was not declared in this scope
    6 | int battle(uint32_t &monster, uint32_r &yu_sya)
      |                                         ^~~~~~
a.cc:6:47: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | int battle(uint32_t &monster, uint32_r &yu_sya)
      |                                               ^
a.cc: In function 'int main(int, const char**)':
a.cc:18:5: error: 'uint32_t' was not declared in this scope
   18 |     uint32_t N;
      |     ^~~~~~~~
a.cc:18:5: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:19:12: error: 'N' was not declared in this scope
   19 |     cin >> N;
      |            ^
a.cc:21:20: error: template argument 2 is invalid
   21 |     vector<uint32_t> A;
      |                    ^
a.cc:22:18: error: expected ';' before 'i'
   22 |     for (uint32_t i = 0; i < N+1; i++) {
      |                  ^~
      |                  ;
a.cc:22:26: error: 'i' was not declared in this scope
   22 |     for (uint32_t i = 0; i < N+1; i++) {
      |                          ^
a.cc:23:17: error: expected ';' before 'tmp'
   23 |         uint32_t tmp;
      |                 ^~~~
      |                 ;
a.cc:24:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   24 |         cin >> tmp;
      |                ^~~
      |                tm
a.cc:25:11: error: request for member 'push_back' in 'A', which is of non-class type 'int'
   25 |         A.push_back(tmp);
      |           ^~~~~~~~~
a.cc:28:20: error: template argument 2 is invalid
   28 |     vector<uint32_t> B;
      |                    ^
a.cc:29:18: error: expected ';' before 'i'
   29 |     for (uint32_t i = 0; i < N; i++) {
      |                  ^~
      |                  ;
a.cc:29:26: error: 'i' was not declared in this scope
   29 |     for (uint32_t i = 0; i < N; i++) {
      |                          ^
a.cc:30:17: error: expected ';' before 'tmp'
   30 |         uint32_t tmp;
      |                 ^~~~
      |                 ;
a.cc:31:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   31 |         cin >> tmp;
      |                ^~~
      |                tm
a.cc:32:11: error: request for member 'push_back' in 'B', which is of non-class type 'int'
   32 |         B.push_back(tmp);
      |           ^~~~~~~~~
a.cc:35:13: error: expected ';' before 'win'
   35 |     uint32_t win = 0;
      |             ^~~~
      |             ;
a.cc:36:13: error: expected ';' before 'nokori_yu_sya'
   36 |     uint32_t nokori_yu_sya = 0;
      |             ^~~~~~~~~~~~~~
      |             ;
a.cc:37:18: error: expected ';' before 'i'
   37 |     for (uint32_t i = 0; i < N + 1; i++) {
      |                  ^~
      |                  ;
a.cc:37:26: error: 'i' was not declared in this scope
   37 |     for (uint32_t i = 0; i < N + 1; i++) {
      |                          ^
a.cc:38:17: error: expected ';' before 'monster'
   38 |         uint32_t monster = A[i];
      |                 ^~~~~~~~
      |                 ;
a.cc:39:17: error: expected ';' before 'yu_sya'
   39 |         uint32_t yu_sya;
      |                 ^~~~~~~
      |                 ;
a.cc:41:13: error: 'yu_sya' was not declared in this scope
   41 |             yu_sya = 0;
      |             ^~~~~~
a.cc:43:13: error: 'yu_sya' was not declared in this scope
   43 |             yu_sya = B[i];
      |             ^~~~~~
a.cc:46:13: error: 'nokori_yu_sya' was not declared in this scope
   46 |         if (nokori_yu_sya > 0) {
      |             ^~~~~~~~~~~~~
a.cc:47:13: error: 'win' was not declared in this scope
   47 |             win += battle(monster, nokori_yu_sya);
      |             ^~~
a.cc:47:27: error: 'monster' was not declared in this scope; did you mean 'const'?
   47 |             win += battle(monster, nokori_yu_sya);
      |                           ^~~~~~~
      |                           const
a.cc:47:26: error: 'battle' cannot be used as a function
   47 |             win += battle(monster, nokori_yu_sya);
      |                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:49:9: error: 'win' was not declared in this scope
   49 |         win += battle(monster, yu_sya);
      |         ^~~
a.cc:49:23: error: 'monster' was not declared in this scope; did you mean 'const'?
   49 |         win += battle(monster, yu_sya);
      |                       ^~~~~~~
      |                       const
a.cc:49:32: error: 'yu_sya' was not declared in this scope
   49 |         win += battle(monster, yu_sya);
      |                                ^~~~~~
a.cc:49:38: error: 'battle' cannot be used as a function
   49 |         win += battle(monster, yu_sya);
      |                                      ^
a.cc:51:9: error: 'nokori_yu_sya' was not declared in this scope
   51 |         nokori_yu_sya = yu_sya;
      |         ^~~~~~~~~~~~~
a.cc:54:13: error: 'win' was not declared in this scope
   54 |     cout << win << endl;
      |             ^~~