Submission #499322

#TimeUsernameProblemLanguageResultExecution timeMemory
499322AktanK blocks (IZhO14_blocks)C++17
0 / 100
1 ms296 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define int long long #define ft first #define sc second using namespace std; const int mod=1e9+7,INF=1e17; int n,k,dp[105][105],mx=-INF,a[105]; main(){ cin >> n >> k; for(int i=1;i<=n;i++){ cin >> a[i]; } for(int i=1;i<=n;i++){ mx=max(mx,a[i]); dp[1][i]=mx; } for(int i=2;i<=k;i++){ for(int j=i+1;j<=n;j++){ int ans=INF,h=a[j]; for(int l=j-1;l>=i-1;l--){ if(dp[i-1][l]+h<ans){ ans=dp[i-1][l]+h; } h=max(h,a[l]); } dp[i][j]=ans; } } cout << dp[k][n]; }

Compilation message (stderr)

blocks.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...