제출 #969563

#제출 시각아이디문제언어결과실행 시간메모리
969563AliHasanliK개의 묶음 (IZhO14_blocks)C++17
53 / 100
1049 ms1372 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; int a[n]; for(int i=0;i<n;i++)cin>>a[i]; //for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl; int dp[k][n]; for(int i=0;i<k;i++)for(int j=0;j<n;j++)dp[i][j]=0;dp[0][0]=a[0]; //for(int i=0;i<k;i++) //{ // for(int j=0;j<n;j++)cout<<dp[i][j]<<" ";cout<<endl; //} for(int i=1;i<n;i++)dp[0][i]=max(dp[0][i-1],a[i]); //for(int i=0;i<n;i++)cout<<dp[0][i]<<" ";cout<<endl; for(int i=1;i<k;i++) for(int j=i;j<n;j++) { if(j==i)dp[i][j]=a[j]+dp[i-1][j-1]; else { int mak=0,ans=999999999; for(int k=j;k>=i;k--) { mak=max(mak,a[k]); ans=min(ans,dp[i-1][k-1]+mak); } dp[i][j]=ans; } } //for(int i=0;i<k;i++) //{ // for(int j=0;j<n;j++)cout<<dp[i][j]<<" ";cout<<endl; //} cout<<dp[k-1][n-1]; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

blocks.cpp: In function 'int main()':
blocks.cpp:11:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   11 |     for(int i=0;i<k;i++)for(int j=0;j<n;j++)dp[i][j]=0;dp[0][0]=a[0];
      |     ^~~
blocks.cpp:11:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   11 |     for(int i=0;i<k;i++)for(int j=0;j<n;j++)dp[i][j]=0;dp[0][0]=a[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...