Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,K;
ll dp[16][16][300];
ll a[20];
vector<ll> index;

int main(void){
	scanf("%d%d",&n,&K);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		for(int j=0;j<15;j++){
			index.push_back((ll)a[i]+j);
		}
	}
	index.push_back(0);
	sort(index.begin(),index.end());
	index.erase(unique(index.begin(),index.end()),index.end());
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=index.size();k++){
				dp[i][j][k]=(ll)n*INF;
			}
		}
	}
	dp[0][0][0]=0;
	for(int i=0;i<n;i++){
		a[i]=lower_bound(index.begin(),index.end(),a[i])-index.begin();
		for(int j=0;j<n;j++){
			for(int k=0;k<index.size();k++){
				dp[i+1][j][max(k,(int)a[i])]=min(dp[i+1][j][max(k,(int)a[i])],dp[i][j][k]);
				if(a[i]>k){
					dp[i+1][j+1][a[i]]=min(dp[i+1][j+1][a[i]],dp[i][j][k]);
				}else{
					ll cost=index[k+1]-index[a[i]];
					dp[i+1][j+1][k+1]=min(dp[i+1][j+1][k+1],dp[i][j][k]+cost);
				}
			}
		}
	}
	ll res=dp[n][K][0];
	for(int i=0;i<index.size();i++){
		res=min(res,dp[n][K][i]);
	}
	printf("%lld\n",res);
	return 0;
}


Compiler output:
a.cc:21:12: error: 'std::vector<long long int> index' redeclared as different kind of entity
   21 | vector<ll> index;
      |            ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:28:31: error: overloaded function with no contextual type information
   28 |                         index.push_back((ll)a[i]+j);
      |                               ^~~~~~~~~
a.cc:31:15: error: overloaded function with no contextual type information
   31 |         index.push_back(0);
      |               ^~~~~~~~~
a.cc:32:20: error: overloaded function with no contextual type information
   32 |         sort(index.begin(),index.end());
      |                    ^~~~~
a.cc:32:34: error: overloaded function with no contextual type information
   32 |         sort(index.begin(),index.end());
      |                                  ^~~
a.cc:33:15: error: overloaded function with no contextual type information
   33 |         index.erase(unique(index.begin(),index.end()),index.end());
      |               ^~~~~
a.cc:33:34: error: overloaded function with no contextual type information
   33 |         index.erase(unique(index.begin(),index.end()),index.end());
      |                                  ^~~~~
a.cc:33:48: error: overloaded function with no contextual type information
   33 |         index.erase(unique(index.begin(),index.end()),index.end());
      |                                                ^~~
a.cc:33:61: error: overloaded function with no contextual type information
   33 |         index.erase(unique(index.begin(),index.end()),index.end());
      |                                                             ^~~
a.cc:36:46: error: overloaded function with no contextual type information
   36 |                         for(int k=0;k<=index.size();k++){
      |                                              ^~~~
a.cc:43:40: error: overloaded function with no contextual type information
   43 |                 a[i]=lower_bound(index.begin(),index.end(),a[i])-index.begin();
      |                                        ^~~~~
a.cc:43:54: error: overloaded function with no contextual type information
   43 |                 a[i]=lower_bound(index.begin(),index.end(),a[i])-index.begin();
      |                                                      ^~~
a.cc:43:72: error: overloaded function with no contextual type information
   43 |                 a[i]=lower_bound(index.begin(),index.end(),a[i])-index.begin();
      |                                                                        ^~~~~
a.cc:45:45: error: overloaded function with no contextual type information
   45 |                         for(int k=0;k<index.size();k++){
      |                                             ^~~~
a.cc:50:54: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   50 |                                         ll cost=index[k+1]-index[a[i]];
      |                                                      ^
a.cc:50:65: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   50 |                                         ll cost=index[k+1]-index[a[i]];
      |                                                                 ^
a.cc:57:29: error: overloaded function with no contextual type information
   57 |         for(int i=0;i<index.size();i++){
      |                             ^~~~