Language: C++

#include <bits/stdc++.h>
using namespace std;

int s[3000][3000]; 
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    for(int i=1;i<h;i++)for(int j=0;j<w;j++)cin >> s[i][j];
    int flag=0;
    int ans=1e9;
    int tmp;
    vector<int> ans;
    for(int i=0;i<(1<<h);i++){
        tmp=__builtin_popcount(i);
        ans.push_back(s[0][0]);
        for(int j=0;j<h-1;j++){
            if(i&(1<<(j+1)))ans.push_back(s[j+1][0]);
            else ans[ans.size()-1]+=s[j+1][0];
            if(ans[ans.size()-1]>k){
                flag++;
                break;
            }
        }
        if(flag>0)break;
        else for(int i=0;i<ans.size();i++)
        for(int l=1;l<w;l++){
            flag=0;
            vector<int> num;
            num.push_back(s[0][l]);
            for(int j=0;j<h-1;j++){
                if(i&(1<<(j+1)))num.push_back(s[j+1][l]);
                else num[num.size()-1]+=s[j+1][l];
                if(num[num.size()-1]>k){
                    flag++;
                    break;
                }
            }
            if(flag>0)break;
            else{
                for(int l=0;l<ans.size();l++){
                    ans[l]+=num[l];
                    if(ans[l]>k){
                        flag++;
                        break;
                    }
                }
                if(flag>0){
                    tmp++;
                    for(int l=0;l<ans.size();l++)ans[l]=num[l];
                }
            }
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: conflicting declaration 'std::vector<int> ans'
   12 |     vector<int> ans;
      |                 ^~~
a.cc:10:9: note: previous declaration as 'int ans'
   10 |     int ans=1e9;
      |         ^~~
a.cc:15:13: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
   15 |         ans.push_back(s[0][0]);
      |             ^~~~~~~~~
a.cc:17:33: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
   17 |             if(i&(1<<(j+1)))ans.push_back(s[j+1][0]);
      |                                 ^~~~~~~~~
a.cc:18:26: error: request for member 'size' in 'ans', which is of non-class type 'int'
   18 |             else ans[ans.size()-1]+=s[j+1][0];
      |                          ^~~~
a.cc:19:24: error: request for member 'size' in 'ans', which is of non-class type 'int'
   19 |             if(ans[ans.size()-1]>k){
      |                        ^~~~
a.cc:25:32: error: request for member 'size' in 'ans', which is of non-class type 'int'
   25 |         else for(int i=0;i<ans.size();i++)
      |                                ^~~~
a.cc:40:35: error: request for member 'size' in 'ans', which is of non-class type 'int'
   40 |                 for(int l=0;l<ans.size();l++){
      |                                   ^~~~
a.cc:41:24: error: invalid types 'int[int]' for array subscript
   41 |                     ans[l]+=num[l];
      |                        ^
a.cc:42:27: error: invalid types 'int[int]' for array subscript
   42 |                     if(ans[l]>k){
      |                           ^
a.cc:49:39: error: request for member 'size' in 'ans', which is of non-class type 'int'
   49 |                     for(int l=0;l<ans.size();l++)ans[l]=num[l];
      |                                       ^~~~
a.cc:49:53: error: invalid types 'int[int]' for array subscript
   49 |                     for(int l=0;l<ans.size();l++)ans[l]=num[l];
      |                                                     ^