Submission #874914

# Submission time Handle Problem Language Result Execution time Memory
874914 2023-11-18T05:31:39 Z Faisal_Saqib Popeala (CEOI16_popeala) C++17
17 / 100
201 ms 262144 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int T=2e4+1;
const int N=51;
const int inf=2e9;
int points,n,t,s;
int pre[T];
int zero[N];
int zeros[T][T];
int dp[T][2];
inline int read() {
    char c = getchar();
    int x = 0, s = 1;
    while (c < '0' || c > '9') {
        if (c == '-')
            s = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * s;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    n=read();
    t=read();
    s=read();
    // scanf("%d %d %d",&n,&t,&s);
    for(int i=0;i<t;i++)
    {
        points=read();
        // scanf("%d",&points);
        pre[i+1]=pre[i]+points;
    }
    char results[t];
    for(int i=0;i<n;i++)
    {
        scanf("%s",results);
        for(int r=1;r<=t;r++)
        {
            if(results[r-1]=='0')
                zero[i]=r;
            else
                zeros[zero[i]+1][r]+=1;
        }
    }
    for(int i=1;i<=t;i++)
    {
        dp[i][0]=inf;
        for(int j=1;j<=i;j++)
            zeros[j][i]+=zeros[j-1][i];
    }
    dp[0][0]=0;
    for(int j=0;j<s;j++)
    {
        for(int i=0;i<=t;i++)
            dp[i][(j+1)%2]=inf;
        for(int i=0;i<t;i++)
        {
            if(dp[i][j%2]==inf)
                continue;
            for(int new_i=i+1;new_i<=t;new_i++)
                dp[new_i][(j+1)%2]=min(dp[new_i][(j+1)%2],dp[i][j%2]+(pre[new_i]-pre[i])*zeros[i+1][new_i]);
        }
        printf("%d\n",dp[t][(j+1)%2]);
    }
    return 0;
}

Compilation message

popeala.cpp: In function 'int main()':
popeala.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%s",results);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 41308 KB Output is correct
2 Correct 8 ms 41308 KB Output is correct
3 Correct 8 ms 41308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 172844 KB Output is correct
2 Correct 201 ms 236476 KB Output is correct
3 Runtime error 31 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 10 ms 41308 KB Output is correct
4 Correct 8 ms 41308 KB Output is correct
5 Correct 8 ms 41308 KB Output is correct
6 Correct 99 ms 172844 KB Output is correct
7 Correct 201 ms 236476 KB Output is correct
8 Runtime error 31 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -