#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 = 64, 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<int> ptsP(t+1);
for (int i = 0; i < t; i++) {
ptsP[i+1] =ptsP[i] + pts[i];
}
vector<string> table(n);
for (auto& i : table) {cin >> i;}
vector<vector<int>> prev(n, vector<int>(t,-1));
for (int c = 0; c < n; c++)
for (int tc = 0;tc < t; tc++)
if (table[c][tc] == '0')
prev[c][tc] = tc;
else if (tc)
prev[c][tc] = prev[c][tc-1];
debug(prev);
int dp[t][s+1];
dp[0][0] = 0;
for (int i = 1; i < t; i++)
dp[i][0] = INF;
for (int i = 0; i < t; i++) {
for (int g = 1; g <= s; g++) {
dp[i][g] = INF;
vector<int> js(n);
for (int k = 0; k < n; k++) {
js[k] = prev[k][i];
}
debug(i, js);
sort(js.begin(), js.end(), greater<>{});
for (int jj = 0; jj < n; jj++) {
int j = js[jj];
int score = ptsP[i+1] - ptsP[max(0, j)];
int cur = score * (n - jj - (j != -1));
if (j <= 0 && g != 1) continue;
if (j > 0) cur += dp[j-1][g-1];
dp[i][g] = min(dp[i][g], cur);
if (j == -1) break;
}
}
}
for (int k = 1; k <= s; k++) {
cout << dp[t-1][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;
}
/*
█████ █████ ███ ████
▒▒███ ▒▒███ ▒▒▒ ▒▒███
███████ ████████ ███████ ████ ▒███ █████ ████ ██████ ████████
███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███ ▒███ ▒▒███ ▒███ ███▒▒███▒▒███▒▒███
▒███ ▒███ ▒███ ▒▒▒ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒
▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███
▒▒████████ █████ ▒▒████████ █████ █████ ▒▒███████ ▒▒██████ █████
▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒███ ▒▒▒▒▒▒ ▒▒▒▒▒
███ ▒███
▒▒██████
▒▒▒▒▒▒
*/
Compilation message
popeala.cpp: In function 'int solve()':
popeala.cpp:5:24: warning: statement has no effect [-Wunused-value]
5 | #define debug(...) 42
| ^~
popeala.cpp:37:5: note: in expansion of macro 'debug'
37 | debug(prev);
| ^~~~~
popeala.cpp:5:24: warning: statement has no effect [-Wunused-value]
5 | #define debug(...) 42
| ^~
popeala.cpp:51:13: note: in expansion of macro 'debug'
51 | debug(i, js);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
66 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |