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;
const int inf = 1e9;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int ppl, cases, grp; cin >> ppl >> cases >> grp;
vector<int> pts(cases + 1);
for (int i = 1; i <= cases; i++) cin >> pts[i];
vector<vector<bool>> ac(ppl, vector<bool>(cases + 1));
for (int i = 0; i < ppl; i++){
string str; cin >> str;
for (int j = 1; j <= cases; j++) ac[i][j] = (str[j - 1] == '1');
}
vector<vector<int>> dp(grp + 1, vector<int>(cases + 1, inf));
dp[0][0] = 0;
for (int i = 1; i <= grp; i++)
for (int j = 1; j <= cases; j++){
vector<bool> ok(ppl, 1);
int ttp = 0;
for (int k = j; k >= i; k--){
int cnt = 0;
for (int l = 0; l < ppl; l++) {
ok[l] = ok[l] & ac[l][k];
cnt += ok[l];
}
ttp += pts[k];
dp[i][j] = min(dp[i][j], dp[i - 1][k - 1] + cnt * ttp);
}
}
for (int i = 1; i <= grp; i++) cout << dp[i][cases] << '\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... |