Submission #207111

#TimeUsernameProblemLanguageResultExecution timeMemory
207111vardan__02K blocks (IZhO14_blocks)C++14
53 / 100
597 ms18912 KiB
#include <algorithm> #include <iostream> #include <fstream> #include <cstring> #include <string> #include <vector> #include <cstdio> #include <queue> #include <deque> #include <stack> #include <list> #include <set> #include <map> using namespace std; typedef long long ll; const long long N=105; const long long inf=1e18; #define MP make_pair #define PB push_back ll n,m,i,j,k,ans[N][N][N],a[N],x; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>k; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) for(j=i;j<=n;j++) for(x=i;x<=j;x++) ans[i][j][1]=max(ans[i][j][1],a[x]); for(ll qanak=1;qanak<=k;qanak++) { for(i=1;i<=n;i++) { for(j=i;j<=n;j++) { ans[i][j][qanak+1]=inf; for(x=i;x<=j-qanak;x++) ans[i][j][qanak+1]=min(ans[i][j][qanak+1],ans[i][x][1]+ans[x+1][j][qanak]); } } } cout<<ans[1][n][k]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...