# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135190 | 2019-07-23T19:24:52 Z | pedro_sponchiado | Split the sequence (APIO14_sequence) | C++17 | 14 ms | 8952 KB |
#include<bits/stdc++.h> using namespace std; const long long int INF=1000000000000000; const int maxn=1010; const int maxk=210; int n, d; int a[maxn]; long long int parc[maxn], parc_2[maxn]; long long int S_2[maxn][maxn]; //long long int S_2(int i, int j){ long long int dp[maxn][maxk]; int main(){ scanf("%d %d", &n, &d); for(int i=1; i<=n; i++){ scanf("%d", &a[i]); parc[i]=parc[i-1]+a[i]; parc_2[i]=parc_2[i-1]+a[i]*a[i]; } for(int i=1; i<=n; i++){ for(int k=i; k<=n; k++){ S_2[i][k]= (parc[k]-parc[i-1])*(parc[k]-parc[i-1])-parc_2[k]+parc_2[i-1]; } } for(int i=1; i<=n; i++) dp[i][0]=S_2[1][i]; for(int k=1; k<=d; k++){ for(int i=1; i<=n; i++){ dp[i][k]=INF; if(k>=i)continue; for(int l=1; l<i; l++){ dp[i][k]=min(dp[i][k], dp[l][k-1]+S_2[l+1][i]); } // printf("dp[%d][%d]=%lld\n", i, k, dp[i][k]); } } printf("%lld/2", S_2[1][n]-dp[n][d]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Expected integer, but "216/2" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 632 KB | Expected integer, but "2187912/2" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1656 KB | Expected integer, but "1221180000/2" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 8952 KB | Expected integer, but "43006808/2" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Expected integer, but "-999999999999948/2" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Expected integer, but "0/2" found |
2 | Halted | 0 ms | 0 KB | - |