# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52869 | 2018-06-27T05:40:08 Z | 윤교준(#1384) | Popeala (CEOI16_popeala) | C++11 | 1174 ms | 13776 KB |
#include <bits/stdc++.h> #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; const int MAXT = 4005; const int MAXN = 55; const int MAXK = 55; int dp[MAXK][MAXT]; int C[MAXT][MAXT]; bool B[MAXN][MAXT]; int BS[MAXN][MAXT]; int S[MAXT]; int A[MAXT]; int N, T, K; int main() { scanf("%d%d%d", &N, &T, &K); for(int i = 1; i <= T; i++) scanf("%d", &A[i]); for(int i = 1; i <= N; i++) { for(int j = 1; j <= T; j++) { char c; scanf(" %c", &c); B[i][j] = (bool)(c == '1'); } } for(int i = 1; i <= T; i++) S[i] = S[i-1] + A[i]; for(int i = 1; i <= N; i++) { for(int j = 1; j <= T; j++) BS[i][j] = BS[i][j-1] + (int)(!!B[i][j]); for(int s = 1; s <= T; s++) for(int e = s; e <= T; e++) if(BS[i][e] - BS[i][s-1] == e-s+1) C[s][e]++; } for(int j = 1; j <= K; j++) { for(int i = j; i <= T; i++) { int t = INF*2; for(int k = j-1; k < i; k++) { ll r = dp[j-1][k] + ll(S[i] - S[k]) * C[k+1][i]; if(r < t) t = r; } dp[j][i] = t; } } for(int i = 1; i <= K; i++) printf("%d\n", dp[i][T]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 1000 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 33 ms | 3764 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1174 ms | 13776 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 1000 KB | Output isn't correct |