#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int MAX = 2e4 + 5;
int n, t, s, dp[55][MAX], p[MAX], chk[55][MAX], bf[55][MAX], ix[MAX][55], pf[MAX];
string w;
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> t >> s;
for(int i = 1; i <= t; i++) cin >> p[i], pf[i] = pf[i - 1] + p[i];
for(int i = 0; i < n; i++){
cin >> w;
for(int j = 0; j < t; j++) chk[i + 1][j + 1] = w[j] - '0';
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= t; j++){
bf[i][j] = (chk[i][j] ? bf[i][j - 1] : j);
ix[j][i - 1] = bf[i][j];
}
for(int i = 1; i <= t; i++) sort(ix[i], ix[i] + n);
for(int j = 1; j <= t; j++){
int score = 0;
for(int i = 1; i <= n; i++)
if(!bf[i][j]) score += pf[j];
dp[1][j] = score;
}
cout << dp[1][t] << '\n';
for(int i = 2; i <= s; i++){
for(int j = i; j <= t; j++){
dp[i][j] = dp[i - 1][j - 1] + p[j] * n;
for(int k = 0; k < n; k++){
if(ix[j][k] >= i) dp[i][j] = min(dp[i][j], dp[i - 1][ix[j][k] - 1] + (pf[j] - pf[ix[j][k] - 1]) * k);
}
//cout << dp[i][j] << ' ';
}
//cout << '\n';
cout << dp[i][t] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
2672 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |