Submission #1363347

#TimeUsernameProblemLanguageResultExecution timeMemory
1363347Ronin13K blocks (IZhO14_blocks)C11
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
int dp[100001][101];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    int k;cin>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[0][0]=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=k;j++)dp[i][j]=inf;
    }
    dp[0][0]=0;
    for(int j=1;j<=k;j++){
        stack<pii>st;
        for(int i=1;i<=n;i++){
            int cur=dp[i-1][j-1];
            while(!st.empty()){
                int x=st.top().f;
                if(a[x]>=a[i])break;
                int y=st.top().s;
                cur=min(cur, dp[x][j] - a[x]);
                st.pop();
            }
            if(!st.empty()){
                int tp=st.top().f;
                dp[i][j]=min({dp[i][j],dp[tp][j],cur+a[i]});
            }
            else{
                dp[i][j]=min(dp[i][j],cur+a[i]);
            }
            st.push({i,cur});
        }
    }
    cout<<dp[n][k]<<' ';
    return 0;
}

Compilation message (stderr)

blocks.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.