# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
874887 | Faisal_Saqib | Popeala (CEOI16_popeala) | C++17 | 679 ms | 262144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int T=2e4+10;
const int N=52;
const int inf=2e9+1;
int points[1];
string results[1];
int pre[T];
int ptr[N];
vector<int> zero[N];
int zeros[T][T];
int dp[T][N];
int main()
{
int n,t,s;
cin>>n>>t>>s;
for(int i=0;i<t;i++)
{
cin>>points[0];
pre[i+1]=pre[i]+points[0];
}
for(int i=0;i<n;i++)
{
cin>>results[0];
ptr[i]=0;
for(int j=0;j<t;j++)
if(results[0][j]=='0')
zero[i].push_back(j);
}
for(int i=0;i<=t;i++)
for(int j=0;j<=s;j++)
dp[i][j]=inf;
// dp[i][j] we spilt the first i testcases into j subtask
dp[0][0]=0;
// dp[i][j] ---> dp[i+1..n][j+1]
for(int l=1;l<=t;l++)
{
for(int r=l;r<=t;r++)
{
zeros[l][r]=n;
for(int i=0;i<n;i++)
{
while(ptr[i]<zero[i].size() and zero[i][ptr[i]]<(l-1))
ptr[i]++;
if(ptr[i]<zero[i].size() and zero[i][ptr[i]] < r)
zeros[l][r]--;
}
}
}
for(int i=0;i<t;i++)
{
for(int j=0;j<s;j++)
{
if(dp[i][j]==inf)
continue;
for(int new_i=i+1;new_i<=t;new_i++)
{
dp[new_i][j+1]=min(dp[new_i][j+1],dp[i][j]+(pre[new_i]-pre[i])*zeros[i+1][new_i]);
}
}
}
for(int j=1;j<=s;j++)
cout<<dp[t][j]<<'\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |