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;
long long N,T,S, A[20005], B[55][20005], dp[20005][55];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> N >> T >> S;
A[0] = 0;
for (long long i = 1; i <= T; ++i) {
cin >> A[i];
A[i] += A[i-1];
}
for (long long i = 1; i <= N; ++i) for (long long j = 1; j <= T; ++j) {
char ch; cin >> ch;
B[i][j] = ch-'0' + B[i][j-1];
}
memset(dp,-1,sizeof(dp));
dp[0][0] = 0;
for (long long i = 1; i <= T; ++i) for (long long j = 1; j <= S && j <= i; ++j) for (long long k = 0; k < i; ++k) if (dp[k][j-1] != -1) {
long long num = 0;
for (long long n = 1; n <= N; ++n) if (B[n][i] - B[n][k] == i-k) num++;
if (dp[i][j] == -1) dp[i][j] = dp[k][j-1] + num * (A[i] - A[k]);
else dp[i][j] = min(dp[i][j], dp[k][j-1] + num * (A[i] - A[k]));
}
for (long long i = 1; i <= S; ++i) cout << dp[T][i] << '\n';
return 0;
}
# | 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... |