Submission #698081

# Submission time Handle Problem Language Result Execution time Memory
698081 2023-02-12T09:09:12 Z abcvuitunggio Popeala (CEOI16_popeala) C++17
17 / 100
2000 ms 9556 KB
#include <iostream>
#include <cstring>
#define int long long
using namespace std;
const int INF=1e18;
int dp[20001][51],n,T,s,t[20001],a[51][20001],cur;
string score[51];
int C(int i, int j){
    int cnt=0;
    for (int k=1;k<=n;k++)
        cnt+=(a[k][j]-a[k][i-1]==j-i+1);
    return (t[j]-t[i-1])*cnt;
}
int f(int i, int j){
    if (j<0)
        return INF;
    if (!i)
        return (j?INF:0);
    if (dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=INF;
    for (int k=j;k<=i;k++)
        dp[i][j]=min(dp[i][j],f(k-1,j-1)+C(k,i));
    return dp[i][j];
}
int32_t main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n >> T >> s;
    for (int i=1;i<=T;i++){
        cin >> t[i];
        t[i]+=t[i-1];
    }
    for (int i=1;i<=n;i++){
        cin >> score[i];
        for (int j=0;j<T;j++)
            a[i][j+1]=a[i][j]+score[i][j]-'0';
    }
    memset(dp,-1,sizeof(dp));
    for (int i=1;i<=s;i++)
        cout << f(T,i) << '\n';
}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 8268 KB Output is correct
2 Correct 4 ms 8392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 335 ms 8768 KB Output is correct
2 Correct 347 ms 8744 KB Output is correct
3 Correct 343 ms 8788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 9556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8268 KB Output is correct
2 Correct 4 ms 8392 KB Output is correct
3 Correct 335 ms 8768 KB Output is correct
4 Correct 347 ms 8744 KB Output is correct
5 Correct 343 ms 8788 KB Output is correct
6 Execution timed out 2058 ms 9556 KB Time limit exceeded
7 Halted 0 ms 0 KB -