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;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define ll long long
const int mN = 55, mT = 20005;
int n, t, s, pts[mT], mat[mN][mT], lft[mT][mN]; ll dp[mT][mN];
int main(){
cin >> n >> t >> s;
FOR(tst, 1, t + 1) cin >> pts[tst], pts[tst] += pts[tst - 1];
FOR(p, 1, n + 1) FOR(tst, 1, t + 1){
char c; cin >> c;
mat[p][tst] = c - '0';
lft[tst][p] = (!mat[p][tst] ? tst : lft[tst - 1][p]);
}
FOR(tst, 1, t + 1) lft[tst][0] = tst, sort(lft[tst], lft[tst] + n + 1);
memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0;
FOR(subT, 1, s + 1){
ll bst[n + 1]; memset(bst, 0x3f, sizeof(bst));
FOR(tst, 1, t + 1){
FOR(correct, 0, n + 1){
FOR(x, lft[tst - 1][correct], lft[tst][correct]){
bst[correct] = min(bst[correct], dp[x][subT - 1] - pts[x] * correct);
}
dp[tst][subT] = min(dp[tst][subT], bst[correct] + pts[tst] * correct);
}
}
cout<<dp[t][subT]<<"\n";
}
}
# | 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... |