#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
int mat[51][20005];
ll dp[51][20005];
signed main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, t, s;
cin >> n >> t >> s;
vector<int> p(t+1);
for(int i=1; i<=t; i++) cin >> p[i];
for(int i=1; i<=n; i++) {
for(int j=1; j<=t; j++) {
char ch;
cin >> ch;
mat[i][j] = (ch == '1');
}
}
for(int i=0; i<=s; i++)
for(int j=0; j<=t; j++) dp[i][j] = 1e18;
dp[0][0] = 0;
for(int j=1; j<=s; j++) {
vector<int> last(n+1), rem(t+1);
for(int i=1; i<=t; i++) {
for(int k=1; k<=n; k++) {
if(!mat[k][i]) {
rem[last[k]]--;
last[k] = i;
rem[last[k]]++;
}
}
ll sum = 0, cnt = n;
for(int k=i; k>=1; k--) {
sum += p[k];
cnt -= rem[k];
dp[j][i] = min(dp[j][i], dp[j-1][k-1] + sum * cnt);
}
}
}
for(int i=1; i<=s; i++) cout << dp[i][t] << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
10844 KB |
Output is correct |
2 |
Correct |
11 ms |
10840 KB |
Output is correct |
3 |
Correct |
10 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
168 ms |
10964 KB |
Output is correct |
2 |
Correct |
297 ms |
11096 KB |
Output is correct |
3 |
Correct |
493 ms |
11228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
12 ms |
10844 KB |
Output is correct |
4 |
Correct |
11 ms |
10840 KB |
Output is correct |
5 |
Correct |
10 ms |
10844 KB |
Output is correct |
6 |
Correct |
168 ms |
10964 KB |
Output is correct |
7 |
Correct |
297 ms |
11096 KB |
Output is correct |
8 |
Correct |
493 ms |
11228 KB |
Output is correct |
9 |
Correct |
1383 ms |
11744 KB |
Output is correct |
10 |
Execution timed out |
2057 ms |
11868 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |