#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int T = 2e4 + 7;
const int N = 50;
const int INF = 2e9;
int n, t, s;
int points[T], task[T], sum[N][T];
int pref[T], dp[N][T];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> t >> s;
for (int i = 1; i <= t; ++i) cin >> points[i];
for (int i = 1; i <= t; ++i) pref[i] = pref[i - 1] + points[i];
for (int i = 1; i <= n; ++i) {
string s;
cin >> s;
for (int j = 0; j < t; ++j) sum[i][j + 1] = sum[i][j] + s[j] - '0';
}
for (int g = 0; g <= s; ++g) for (int i = 0; i <= t; ++i) dp[i][g] = INF;
dp[0][0] = 0;
for (int g = 1; g <= s; ++g) {
for (int i = 1; i <= t; ++i) {
for (int j = 1; j <= i; ++j) {
int score = 0;
for (int guy = 1; guy <= n; ++guy) {
if (sum[guy][i] - sum[guy][j - 1] == i - j + 1) {
score += pref[i] - pref[j - 1];
}
}
dp[i][g] = min(dp[i][g], dp[j - 1][g - 1] + score);
}
}
}
for (int i = 1; i <= s; ++i) cout << dp[t][i] << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
6232 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Runtime error |
5 ms |
5464 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |