Submission #272687

# Submission time Handle Problem Language Result Execution time Memory
272687 2020-08-18T13:35:22 Z Killer2501 K blocks (IZhO14_blocks) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define taks "blocks"
#define fi first
#define se second
#define pll pair<ll, ll>
using namespace std;
const ll N = 2e5 + 5;
const ll mod = 1e9 + 7;
ll n, sum= 0, m, tong, k, ans, T, t;

ll a[N], dp[N][102];
string s;
vector<pll> adj[N];
ll f(ll i, ll j)
{
    return (i-1) * m + j;
}
char c[N];
inline void sol()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    for(int i = 1; i <= n; i ++)
    {
        dp[i][1] = max(dp[i-1][1], a[i]);
        dp[0][i] = mod;
        //cout << dp[i][1] <<" ";
    }
    for(int j = 2; j <= k; j ++)
    {
        stack<pll> ds;
        for(int i = j; i <= n; i ++)
        {
            ll mn = dp[i-1][j-1];
            while(!ds.empty() && a[ds.top().se] <= a[i])
            {

                mn = min(mn, ds.top().fi);
                ds.pop();
            }
            dp[i][j] = min(dp[ds.empty() ? 0 : ds.top().se][j-1], mn + a[i]);
            ds.push({mn, i});
            //cout << dp[i][j] <<' ';
        }
        //cout << '\n';
    }
    cout << dp[n][k];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".in", "r"))
    {
        freopen(task".in", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    sol();
}

Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:56:14: error: 'task' was not declared in this scope; did you mean 'taks'?
   56 |     if(fopen(task".in", "r"))
      |              ^~~~
      |              taks
blocks.cpp:58:21: error: expected ')' before string constant
   58 |         freopen(task".in", "r", stdin);
      |                ~    ^~~~~
      |                     )
blocks.cpp:59:21: error: expected ')' before string constant
   59 |         freopen(task".out", "w", stdout);
      |                ~    ^~~~~~
      |                     )