제출 #208007

#제출 시각아이디문제언어결과실행 시간메모리
208007rzbt수열 (APIO14_sequence)C++14
0 / 100
116 ms888 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 1005 #define MAXK 55 typedef long long ll; using namespace std; int n,u; int dp[MAXN][MAXK]; int niz[MAXN]; int suma[MAXN]; int sec[MAXN][MAXK]; int resi(int d,int k){ if(dp[d][k]!=-1)return dp[d][k]; if(k==0 || d==1){ //printf(" %d %d %d %d\n",l,d,k,dp[l][d][k]); return dp[d][k]=0; } for(int i=k+1;i<=d;i++){ int tr=suma[i-1]*(suma[d]-suma[i-1])+resi(i-1,k-1); if(tr>dp[d][k]){ sec[d][k]=i-1; dp[d][k]=tr; } } //printf(" %d %d %d %d\n",l,d,k,dp[l][d][k]); return dp[d][k]; } int main() { scanf("%d %d", &n, &u); for(int i=0;i<=n;i++){ for(int j=0;j<=u;j++){ dp[i][j]=-1; } } for(int i=1;i<=n;i++) scanf("%d",niz+i); for(int i=1;i<=n;i++) suma[i]=suma[i-1]+niz[i]; printf("%d\n",resi(n,u)); int poc=n; for(int i=u;i>0;i--){ poc=sec[poc][i]; printf("%d ",poc); } return 0; }

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

sequence.cpp: In function 'int main()':
sequence.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &u);
     ~~~~~^~~~~~~~~~~~~~~~~
sequence.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",niz+i);
         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...