제출 #93594

#제출 시각아이디문제언어결과실행 시간메모리
93594dragonslayerit수열 (APIO14_sequence)C++14
50 / 100
2062 ms6776 KiB
#include <cstdio> #include <stdint.h> #include <algorithm> int64_t as[100005]; int64_t prefix[100005]; int64_t dp[201][100005]; int64_t from[201][100005]; int main(){ int64_t N,K; scanf("%ld %ld",&N,&K); for(int64_t i=1;i<=N;i++){ scanf("%ld",&as[i]); prefix[i]=as[i]+prefix[i-1]; } for(int64_t k=1;k<=K+1;k++){ for(int64_t i=1;i<=N;i++){ for(int64_t j=0;j<i;j++){ int64_t to=dp[k-1][j]+prefix[j]*(prefix[i]-prefix[j]); if(dp[k][i]<=to){ dp[k][i]=to; from[k][i]=j; } } //printf("dp[%ld][%ld]=%ld\n",k,i,dp[k][i]); } } printf("%ld\n",dp[K][N]); for(int64_t k=K;k>0;k--){ printf("%ld",N=from[k][N]); if(k>1) printf(" "); else printf("\n"); } return 0; }

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

sequence.cpp: In function 'int main()':
sequence.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%ld %ld",&N,&K);
   ~~~~~^~~~~~~~~~~~~~~~~
sequence.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%ld",&as[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...