#include <bits/stdc++.h>
#ifdef ONPC
#include "t_debug.cpp"
#else
#define debug(...) 42
#endif
#define sz(a) ((int)(a).size())
using namespace std;
using ll = long long;
const int INF = 2e9+1;
const ll INFL = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
const int N = 2e4, LOGN = 17, K = 50, MOD = 1e9+7;
int solve() {
int n, t, s;
cin >> n >> t >> s;
if (!cin) return 1;
vector<int> pts(t);
for (auto& i : pts) {cin >> i;}
vector<string> res(n);
for (auto& i : res) {cin >> i;}
int memo[N][K+1];
memset(memo, -1, sizeof(memo));
function<int(int,int)> dp = [&](int i, int g) {
if (!g) return i == t ? 0 : INF;
if (i >= t) return INF;
if (memo[i][g] != -1) return memo[i][g];
int mn = INF;
int score = 0, solved_count = n;
vector<char> solved(n, 1);
for (int j = i; j < t; j++) {
score += pts[j];
for (int c = 0; c < n; c++) {
if (res[c][j] == '0' && solved[c]) {
solved[c] = 0;
solved_count--;
}
}
mn = min(mn, score * solved_count + dp(j+1, g-1));
}
return memo[i][g] = mn;
};
for (int k = 1; k <= s; k++) {
cout << dp(0, k) << '\n';
}
return 0;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
#ifdef ONPC
t = 10000;
#endif
while (t-- && cin) {
if (solve()) break;
#ifdef ONPC
cout << "____________________" << endl;
#endif
}
return 0;
}
/*
█████ █████ ███ ████
▒▒███ ▒▒███ ▒▒▒ ▒▒███
███████ ████████ ███████ ████ ▒███ █████ ████ ██████ ████████
███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███ ▒███ ▒▒███ ▒███ ███▒▒███▒▒███▒▒███
▒███ ▒███ ▒███ ▒▒▒ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒
▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███
▒▒████████ █████ ▒▒████████ █████ █████ ▒▒███████ ▒▒██████ █████
▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒███ ▒▒▒▒▒▒ ▒▒▒▒▒
███ ▒███
▒▒██████
▒▒▒▒▒▒
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4308 KB |
Output is correct |
2 |
Correct |
3 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
585 ms |
4344 KB |
Output is correct |
2 |
Correct |
690 ms |
4364 KB |
Output is correct |
3 |
Correct |
590 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2065 ms |
4436 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4308 KB |
Output is correct |
2 |
Correct |
3 ms |
4308 KB |
Output is correct |
3 |
Correct |
585 ms |
4344 KB |
Output is correct |
4 |
Correct |
690 ms |
4364 KB |
Output is correct |
5 |
Correct |
590 ms |
4352 KB |
Output is correct |
6 |
Execution timed out |
2065 ms |
4436 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |