# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
134944 | 2019-07-23T13:08:24 Z | wilwxk | 수열 (APIO14_sequence) | C++14 | 2000 ms | 39712 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN=1e5+5; const ll INF=1e18; ll dp[MAXN][205]; int opt[MAXN][205]; ll soma[MAXN]; ll v[MAXN]; int n, x; int main() { scanf("%d %d", &n, &x); for(int i=1; i<=n; i++) scanf("%lld", &v[i]); for(int i=1; i<=n; i++) soma[i]=soma[i-1], soma[i]+=v[i]; dp[0][0]=0; for(int i=1; i<=x; i++) dp[0][i]=-INF; for(int i=1; i<=n; i++) { for(int j=1; j<=x; j++) { dp[i][j]=dp[i-1][j-1]+v[i]; opt[i][j]=i-1; for(int k=0; k<i; k++) { ll val=dp[k][j-1]+(soma[i]-soma[k])*soma[k]; if(val>dp[i][j]) { dp[i][j]=val; opt[i][j]=k; } } // printf("%d %d >> %lld\n", i, j, dp[i][j]); } } printf("%lld\n", dp[n][x]); vector<int> respf; int ind=n; while(ind!=0) { respf.push_back(opt[ind][x-1]); ind=opt[ind][--x]; } reverse(respf.begin(), respf.end()); for(auto cur : respf) printf("%d ", cur+1); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | contestant found the optimal answer: 108 == 108 |
2 | Incorrect | 2 ms | 376 KB | declared answer doesn't correspond to the split scheme: declared = 999, real = 719 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Integer 50 violates the range [1, 49] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 888 KB | declared answer doesn't correspond to the split scheme: declared = 610590000, real = 507121050 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2680 KB | declared answer doesn't correspond to the split scheme: declared = 21503404, real = 21169074 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 733 ms | 24640 KB | declared answer doesn't correspond to the split scheme: declared = 1818678304, real = 1396709524 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2043 ms | 39712 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |