# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
682970 |
2023-01-17T11:46:41 Z |
Rafi22 |
Popeala (CEOI16_popeala) |
C++14 |
|
276 ms |
262144 KB |
#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=100000000007;
const int N=20007,M=52;
ll DP[N][M];
ll a[N];
char is[M][N];
int last[M];
vector<ll>P[N][M];
int ile[N];
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++)
{
P[0][i].resize(m+1);
for(int l=0;l<=m;l++) P[0][i][l]=infl;
}
P[0][0].resize(m+1,0);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(is[j][i]=='0')
{
ile[last[j]]--;
last[j]=i;
ile[j]++;
}
}
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]+(ll)(m-l-1)*a[i]);
}
DP[i][j]=min(DP[i][j],P[i-1][j-1][m]+(ll)m*a[i]);
}
for(int j=0;j<=s;j++)
{
P[i][j].resize(m+1);
for(int l=0;l<=m;l++)
{
P[i][j][l]=min(P[i-1][j][l],DP[i][j]-(ll)l*a[i]);
}
}
if(ile[i]==0)
{
for(int j=0;j<=s;j++)
{
P[i-1][j].resize(0);
}
}
}
for(int i=1;i<=s;i++) cout<<DP[n][i]<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24788 KB |
Output is correct |
2 |
Correct |
14 ms |
25028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
35556 KB |
Output is correct |
2 |
Correct |
22 ms |
35092 KB |
Output is correct |
3 |
Correct |
22 ms |
35556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
70036 KB |
Output is correct |
2 |
Correct |
99 ms |
88748 KB |
Output is correct |
3 |
Correct |
106 ms |
110012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24788 KB |
Output is correct |
2 |
Correct |
14 ms |
25028 KB |
Output is correct |
3 |
Correct |
22 ms |
35556 KB |
Output is correct |
4 |
Correct |
22 ms |
35092 KB |
Output is correct |
5 |
Correct |
22 ms |
35556 KB |
Output is correct |
6 |
Correct |
57 ms |
70036 KB |
Output is correct |
7 |
Correct |
99 ms |
88748 KB |
Output is correct |
8 |
Correct |
106 ms |
110012 KB |
Output is correct |
9 |
Correct |
149 ms |
163220 KB |
Output is correct |
10 |
Correct |
201 ms |
205848 KB |
Output is correct |
11 |
Runtime error |
276 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |