#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() {
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++) {
for(int i=1; i<=t; i++) {
ll sum = 0, cnt = n;
vector<int> bad(n+1);
for(int k=i; k>=1; k--) {
sum += p[k];
for(int x=1; x<=n; x++) {
if(!bad[x] && mat[x][k] == 0) {
bad[x] = 1;
cnt--;
} else if(mat[x][k] == 0) bad[x] = 1;
}
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 |
383 ms |
10844 KB |
Output is correct |
2 |
Correct |
359 ms |
10840 KB |
Output is correct |
3 |
Correct |
427 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
10844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
383 ms |
10844 KB |
Output is correct |
4 |
Correct |
359 ms |
10840 KB |
Output is correct |
5 |
Correct |
427 ms |
10844 KB |
Output is correct |
6 |
Execution timed out |
2075 ms |
10844 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |