Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int n,count=0,last,a,b;
  
  cin >> n;
  int p[n] ;
  for(int i=0;i<n+1;i++){
 	 cin >> a[i];
  }
    for(int i=0;i<n;i++){
 	 cin >> b[i];
  }
  
  int max = 0;
   if(b[0] <= a[0]){
         max+=b[0];
         b[0] = 0;
       }else{
         max+=a[0];
         b[0]-=a[0];
       }
  for(int i=1;i<n+1;i++){
 	 if(b[i-1]<=a[i]){
       max+=b[i-1];
       a[i] -= b[i-1];
       if(b[i] <= a[i]){
         max+=b[i];
         b[i] = 0;
       }else{
         max+=a[i];
         b[i]-=a[i];
       }
     else{
       max+=a[i];
       a[i] = 0;

     }
       
  }
  
  
  
  
 

}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:18: error: invalid types 'int[int]' for array subscript
   11 |          cin >> a[i];
      |                  ^
a.cc:14:18: error: invalid types 'int[int]' for array subscript
   14 |          cin >> b[i];
      |                  ^
a.cc:18:8: error: invalid types 'int[int]' for array subscript
   18 |    if(b[0] <= a[0]){
      |        ^
a.cc:18:16: error: invalid types 'int[int]' for array subscript
   18 |    if(b[0] <= a[0]){
      |                ^
a.cc:19:16: error: invalid types 'int[int]' for array subscript
   19 |          max+=b[0];
      |                ^
a.cc:20:11: error: invalid types 'int[int]' for array subscript
   20 |          b[0] = 0;
      |           ^
a.cc:22:16: error: invalid types 'int[int]' for array subscript
   22 |          max+=a[0];
      |                ^
a.cc:23:11: error: invalid types 'int[int]' for array subscript
   23 |          b[0]-=a[0];
      |           ^
a.cc:23:17: error: invalid types 'int[int]' for array subscript
   23 |          b[0]-=a[0];
      |                 ^
a.cc:26:14: error: invalid types 'int[int]' for array subscript
   26 |          if(b[i-1]<=a[i]){
      |              ^
a.cc:26:22: error: invalid types 'int[int]' for array subscript
   26 |          if(b[i-1]<=a[i]){
      |                      ^
a.cc:27:14: error: invalid types 'int[int]' for array subscript
   27 |        max+=b[i-1];
      |              ^
a.cc:28:9: error: invalid types 'int[int]' for array subscript
   28 |        a[i] -= b[i-1];
      |         ^
a.cc:28:17: error: invalid types 'int[int]' for array subscript
   28 |        a[i] -= b[i-1];
      |                 ^
a.cc:29:12: error: invalid types 'int[int]' for array subscript
   29 |        if(b[i] <= a[i]){
      |            ^
a.cc:29:20: error: invalid types 'int[int]' for array subscript
   29 |        if(b[i] <= a[i]){
      |                    ^
a.cc:30:16: error: invalid types 'int[int]' for array subscript
   30 |          max+=b[i];
      |                ^
a.cc:31:11: error: invalid types 'int[int]' for array subscript
   31 |          b[i] = 0;
      |           ^
a.cc:33:16: error: invalid types 'int[int]' for array subscript
   33 |          max+=a[i];
      |                ^
a.cc:34:11: error: invalid types 'int[int]' for array subscript
   34 |          b[i]-=a[i];
      |           ^
a.cc:34:17: error: invalid types 'int[int]' for array subscript
   34 |          b[i]-=a[i];
      |                 ^
a.cc:36:6: error: expected '}' before 'else'
   36 |      else{
      |      ^~~~
a.cc:26:26: note: to match this '{'
   26 |          if(b[i-1]<=a[i]){
      |                          ^
a.cc:37:14: error: invalid types 'int[int]' for array subscript
   37 |        max+=a[i];
      |              ^
a.cc:38:9: error: invalid types 'int[int]' for array subscript
   38 |        a[i] = 0;
      |         ^