# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536957 | 2022-03-14T08:12:16 Z | dantoh000 | Popeala (CEOI16_popeala) | C++14 | 37 ms | 1496 KB |
#include <bits/stdc++.h> using namespace std; int n,t,s; int p[505]; int r[55][505]; int mem[505][55]; int ct[505][505]; const int INF = 2000000001; int dp(int id, int k){ if (id == 0) return 0; if (k == 0) return INF; if (mem[id][k] != -1) return mem[id][k]; int ret = INF; for (int j = id-1; j >= k-1; j--){ ret = min(ret, dp(j,k-1) + (p[id]-p[j])*ct[j+1][id]); } //printf("dp %d %d = %d\n",id,k,ret); return mem[id][k] = ret; } int main(){ scanf("%d%d%d",&n,&t,&s); if (t > 500) return 0; for (int i = 1; i <= t; i++){ scanf("%d",&p[i]); p[i] += p[i-1]; } for (int i = 0; i < n; i++){ for (int j = 1 ; j <= t; j++){ char ch; scanf(" %c",&ch); r[i][j] = ch-'0'; } } for (int k = 0; k < n; k++){ for (int i = 1; i <= t; i++){ int cur = r[k][i]; ct[i][i] += cur; for (int j = i+1; j <= t; j++){ if (r[k][j] == 0) cur = 0; ct[i][j] += cur; } } } memset(mem,-1,sizeof(mem)); for (int i = 1; i <= s; i++){ printf("%d\n", dp(t,i)); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 1492 KB | Output is correct |
2 | Correct | 35 ms | 1392 KB | Output is correct |
3 | Correct | 37 ms | 1496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 32 ms | 1492 KB | Output is correct |
4 | Correct | 35 ms | 1392 KB | Output is correct |
5 | Correct | 37 ms | 1496 KB | Output is correct |
6 | Incorrect | 0 ms | 212 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |