#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxt = 2e4 + 2;
const int maxn = 51;
int dp[maxt][maxn]; // dp[i][j] -> minimum score divinding first i tests in j subtasks
int a[maxt];
int pref[maxn][maxt];
int sum[maxn];
int prec[maxt][maxt];
string s[maxn];
int main() {
int n,t,mk;
cin >> n >> t >> mk;
for (int i = 0; i < maxt; i++) for (int j = 0; j < maxn; j++) dp[i][j] = 2e9;
for (int i = 1; i <= t; i++){
cin >> a[i];
sum[i] = sum[i-1] + a[i];
}
for (int i = 1; i <= n; i++){
cin >> s[i];
for (int j = 1; j <= t; j++){
pref[i][j] = pref[i][j-1] + (s[i][j-1] - '0');
}
}
for (int i = 1; i <= t; i++){
dp[i][1] = 0;
for (int j = 1; j <= n; j++){
if (pref[j][i] == i) dp[i][1]+=sum[i];
}
}
for (int i = 1; i <= t; i++){
for (int j = 1; j < i; j++){
for (int l = 1; l <= n; l++){
if (pref[l][i] - pref[l][j] == i - j) prec[i][j]+=sum[i] - sum[j];
}
}
}
for (int k = 2; k <= mk; k++){
for (int i = 1; i <= t; i++){
for (int j = 1; j < i; j++){
dp[i][k] = min(dp[i][k], prec[i][j] + dp[j][k-1]);
}
}
}
// for (int i = 1; i <= mk; i++){
// for (int j = 1; j <= t; j++){
// cout << dp[j][i] << " ";
// }
// cout << "\n";
// }
for (int i = 1; i <= mk; i++){
cout << dp[t][i] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4308 KB |
Output is correct |
2 |
Correct |
4 ms |
4532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
7196 KB |
Output is correct |
2 |
Correct |
23 ms |
7176 KB |
Output is correct |
3 |
Correct |
22 ms |
7100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
293 ms |
17100 KB |
Output is correct |
2 |
Correct |
569 ms |
27316 KB |
Output is correct |
3 |
Correct |
985 ms |
47172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4308 KB |
Output is correct |
2 |
Correct |
4 ms |
4532 KB |
Output is correct |
3 |
Correct |
24 ms |
7196 KB |
Output is correct |
4 |
Correct |
23 ms |
7176 KB |
Output is correct |
5 |
Correct |
22 ms |
7100 KB |
Output is correct |
6 |
Correct |
293 ms |
17100 KB |
Output is correct |
7 |
Correct |
569 ms |
27316 KB |
Output is correct |
8 |
Correct |
985 ms |
47172 KB |
Output is correct |
9 |
Execution timed out |
2061 ms |
115948 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |