Submission #588937

# Submission time Handle Problem Language Result Execution time Memory
588937 2022-07-04T08:00:20 Z andrei_boaca Popeala (CEOI16_popeala) C++14
17 / 100
2000 ms 46940 KB
#include <bits/stdc++.h>
 
using namespace std;
int dp[20005][55];
int cost[4005][4005];
int n,t,s;
int val[20005];
bool have[55][20005];
bool bad[55];
int mycost[55];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>t>>s;
    for(int i=1;i<=t;i++)
        cin>>val[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=t;j++)
        {
            char c;
            cin>>c;
            have[i][j]=c-'0';
        }
    for(int i=1;i<=t;i++)
    {
        for(int j=1;j<=n;j++)
        {
            bad[j]=0;
            mycost[j]=0;
        }
        int cur=0;
        for(int j=i;j<=t;j++)
        {
            for(int k=1;k<=n;k++)
                if(!bad[k])
                {
                    if(have[k][j])
                    {
                        cur+=val[j];
                        mycost[k]+=val[j];
                    }
                    else
                    {
                        bad[k]=1;
                        cur-=mycost[k];
                        mycost[k]=0;
                    }
                }
            cost[i][j]=cur;
        }
    }
    dp[0][0]=0;
    for(int i=1;i<=s;i++)
        dp[0][i]=2e9;
    for(int i=1;i<=t;i++)
    {
        dp[i][0]=2e9;
        for(int j=1;j<=s;j++)
        {
            dp[i][j]=2e9;
            for(int k=i-1;k>=0;k--)
                dp[i][j]=min(dp[i][j],dp[k][j-1]+cost[k+1][i]);
        }
    }
    for(int i=1;i<=s;i++)
        cout<<dp[t][i]<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 3156 KB Output is correct
2 Correct 18 ms 3144 KB Output is correct
3 Correct 17 ms 3184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 728 ms 19540 KB Output is correct
2 Correct 1700 ms 31096 KB Output is correct
3 Execution timed out 2087 ms 46940 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 18 ms 3156 KB Output is correct
4 Correct 18 ms 3144 KB Output is correct
5 Correct 17 ms 3184 KB Output is correct
6 Correct 728 ms 19540 KB Output is correct
7 Correct 1700 ms 31096 KB Output is correct
8 Execution timed out 2087 ms 46940 KB Time limit exceeded
9 Halted 0 ms 0 KB -