/// NHDanDz
#include <bits/stdc++.h>
#define nmax 100005
#define F first
#define S second
#define PB push_back
#define PF push_front
#define ll long long
//#define int ll
#define RyoLoveHentai "blocks"
#define pii pair<int,int>
#define reset(a) memset(a,0,sizeof(a))
using namespace std;
int n , k , a[nmax] , d[105][nmax];
int main()
{
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
cin >> a[i];
}
memset(d, 0x3f, sizeof d);
d[1][0] = 0;
for(int i = 1; i <= n ; i++)
d[1][i] = max(d[1][i - 1] , a[i]);
for(int i = 2; i <= k; i++)
{
stack <pii> S;
for(int j = i; j <= n; j++)
{
int MINF = d[i - 1][j - 1];
//cout << MINF << " ";
while(!S.empty() && a[S.top().S] <= a[j])
{
MINF = min(MINF , S.top().F);
S.pop();
}
d[i][j] = min(d[i][S.empty() ? 0 : S.top().second] , MINF + a[j]);
//cout << (S.size() ? S.top().S : 0) << " ";
S.push(make_pair(minF, j));
}
//cout << endl;
}
cout << d[k][n];
return 0;
}
Compilation message
blocks.cpp: In function 'int main()':
blocks.cpp:40:30: error: 'minF' was not declared in this scope
S.push(make_pair(minF, j));
^~~~
blocks.cpp:40:30: note: suggested alternative: 'main'
S.push(make_pair(minF, j));
^~~~
main