#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;
const int N=20007,M=57;
int DP[N][M];
int a[N];
char is[M][N];
int last[M];
int P[N][M][M];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int m,n,s;
cin>>m>>n>>s;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) a[i]+=a[i-1];
for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) cin>>is[i][j];
for(int i=1;i<=s;i++) DP[0][i]=infl;
for(int i=1;i<=s;i++) for(int l=0;l<=m;l++) P[0][i][l]=infl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++) if(is[j][i]=='0') last[j]=i;
vector<int>V;
for(int j=1;j<=m;j++) if(last[j]>0) V.pb(last[j]);
sort(all(V),greater<int>());
DP[i][0]=infl;
for(int j=1;j<=s;j++)
{
DP[i][j]=infl;
if(j>i) continue;
for(int l=0;l<sz(V);l++)
{
DP[i][j]=min(DP[i][j],P[V[l]-1][j-1][m-l-1]+(m-l-1)*a[i]);
}
DP[i][j]=min(DP[i][j],P[i-1][j-1][m]+m*a[i]);
}
for(int j=0;j<=s;j++)
{
for(int l=0;l<=m;l++)
{
P[i][j][l]=min(P[i-1][j][l],DP[i][j]-l*a[i]);
}
}
}
for(int i=1;i<=s;i++) cout<<DP[n][i]<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
6996 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
29048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |