Submission #1101482

#TimeUsernameProblemLanguageResultExecution timeMemory
1101482nhutranK blocks (IZhO14_blocks)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define is insert #define ed end() #define fi first #define se second #define bg begin() #define pb push_back #define vll vector <ll> #define mask(k) (1<<(k)) #define mll map <ll, ll> #define pll pair <ll, ll> #define ppl pair <ll, pll> using namespace std; ll n,k,i,j,pos,l,r,mid; int a[100005]; int b[100001][101]; int b[100001][55]; ll ans,m; int get(ll l, ll r) { ll k=__lg(r-l+1); return max(b[l][k],b[r-mask(k)+1][k]); } int main() { cin>>n>>m; for (i=1; i<=n; i++) { cin>>a[i]; b[i][0]=a[i]; } for (j=1; mask(j)<=n; j++) for (i=1; i+mask(j)-1<=n; i++) b[i][j]=max(b[i][j-1],b[i+mask(j-1)][j-1]); memset(dp,0x3f,sizeof dp); dp[0][0]=0; for (i=1; i<=m; i++) for (j=1; j<=n; j++) { for (k=1; k<=j; k++) dp[i][j]=min(dp[i][j],dp[i-1][k-1]+get(k,j)); } cout<<dp[m][n]; return 0; }

Compilation message (stderr)

blocks.cpp:20:5: error: conflicting declaration 'int b [100001][55]'
   20 | int b[100001][55];
      |     ^
blocks.cpp:19:5: note: previous declaration as 'int b [100001][101]'
   19 | int b[100001][101];
      |     ^
blocks.cpp: In function 'int main()':
blocks.cpp:40:12: error: 'dp' was not declared in this scope
   40 |     memset(dp,0x3f,sizeof dp);
      |            ^~