#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int T = 4001;
const int N = 51;
const int S = 51;
const int INF = 2e9 + 10;
int n, t, s, p[T], dp[S][T];
string a[N];
void ReadInput(){
cin >> n >> t >> s;
for(int i = 1; i <= t; i++)
cin >> p[i];
for(int i = 1; i <= n; i++){
cin >> a[i];
a[i] = '*' + a[i];
}
}
int Cost(int l, int r){
int sum = 0, cnt = 0;
for(int i = l; i <= r; i++)
sum += p[i];
for(int i = 1; i <= n; i++){
bool flag = 0;
for(int j = l; j <= r; j++)
if (a[i][j] == '0'){
flag = 1;
break;
}
if (!flag)
cnt++;
}
return sum * cnt;
}
void Solve(){
for(int i = 1; i <= t; i++)
dp[1][i] = Cost(1, i);
for(int i = 2; i <= s; i++)
for(int j = i; j <= t; j++){
dp[i][j] = INF;
for(int k = i; k <= j; k++)
dp[i][j] = min(dp[i][j], dp[i - 1][k - 1] + Cost(k, j));
}
for(int i = 1; i <= s; i++)
cout << dp[i][t] << '\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ReadInput();
Solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2075 ms |
728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2078 ms |
748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Execution timed out |
2075 ms |
728 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |