# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205713 | 2020-02-29T15:02:47 Z | PeppaPig | Popeala (CEOI16_popeala) | C++14 | 353 ms | 10232 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2e4+5; int n, t, s; int A[N], pre[N][55], dp[55][N], mn[55]; int main() { fill_n(dp[0], 55 * N, INT_MAX); scanf("%d %d %d", &n, &t, &s); for(int i = 1; i <= t; i++) scanf("%d", A + i), A[i] += A[i-1]; for(int i = 1; i <= n; i++) { char S[N]; scanf(" %s", S + 1); for(int j = 1; j <= t; j++) { if(S[j] == '0') pre[j][i] = j; else pre[j][i] = pre[j-1][i]; } } for(int i = 1; i <= t; i++) { pre[i][n + 1] = i; sort(pre[i] + 1, pre[i] + n + 1); } dp[0][0] = 0; for(int k = 1; k <= s; k++) { fill_n(mn, 55, 2e9); for(int i = 1; i <= t; i++) { for(int j = 0; j <= n; j++) { for(int l = pre[i - 1][j + 1]; l < pre[i][j + 1]; l++) mn[j] = min(mn[j], dp[k-1][l] - A[l] * j); if(pre[i][j + 1]) dp[k][i] = min(dp[k][i], mn[j] + A[i] * j); } } printf("%d\n", dp[k][t]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 4600 KB | Output is correct |
2 | Correct | 8 ms | 4728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 4732 KB | Output is correct |
2 | Correct | 16 ms | 4728 KB | Output is correct |
3 | Correct | 16 ms | 4728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 5244 KB | Output is correct |
2 | Correct | 69 ms | 5512 KB | Output is correct |
3 | Correct | 82 ms | 5752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 4600 KB | Output is correct |
2 | Correct | 8 ms | 4728 KB | Output is correct |
3 | Correct | 17 ms | 4732 KB | Output is correct |
4 | Correct | 16 ms | 4728 KB | Output is correct |
5 | Correct | 16 ms | 4728 KB | Output is correct |
6 | Correct | 52 ms | 5244 KB | Output is correct |
7 | Correct | 69 ms | 5512 KB | Output is correct |
8 | Correct | 82 ms | 5752 KB | Output is correct |
9 | Correct | 107 ms | 6524 KB | Output is correct |
10 | Correct | 164 ms | 7032 KB | Output is correct |
11 | Correct | 289 ms | 10232 KB | Output is correct |
12 | Correct | 303 ms | 10104 KB | Output is correct |
13 | Correct | 352 ms | 10104 KB | Output is correct |
14 | Correct | 343 ms | 10232 KB | Output is correct |
15 | Correct | 353 ms | 10232 KB | Output is correct |