# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536957 | dantoh000 | Popeala (CEOI16_popeala) | C++14 | 37 ms | 1496 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |