답안 #682971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682971 2023-01-17T11:47:42 Z Rafi22 조교 (CEOI16_popeala) C++14
26 / 100
199 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=1000000000000000007;

const int N=20007,M=52;

int DP[N][M];
int a[N];
char is[M][N];
int last[M];
int P[N][M][M];

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++) for(int l=0;l<=m;l++) P[0][i][l]=infl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++) if(is[j][i]=='0') last[j]=i;
        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]+(m-l-1)*a[i]);
            }
            DP[i][j]=min(DP[i][j],P[i-1][j-1][m]+m*a[i]);
        }
        for(int j=0;j<=s;j++)
        {
            for(int l=0;l<=m;l++)
            {
                P[i][j][l]=min(P[i-1][j][l],DP[i][j]-l*a[i]);
            }
        }
    }
    for(int i=1;i<=s;i++) cout<<DP[n][i]<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 11348 KB Output is correct
2 Correct 9 ms 11344 KB Output is correct
3 Correct 12 ms 11348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 48224 KB Output is correct
2 Correct 52 ms 65484 KB Output is correct
3 Correct 74 ms 87200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 836 KB Output is correct
3 Correct 9 ms 11348 KB Output is correct
4 Correct 9 ms 11344 KB Output is correct
5 Correct 12 ms 11348 KB Output is correct
6 Correct 38 ms 48224 KB Output is correct
7 Correct 52 ms 65484 KB Output is correct
8 Correct 74 ms 87200 KB Output is correct
9 Correct 119 ms 141392 KB Output is correct
10 Correct 145 ms 184436 KB Output is correct
11 Runtime error 199 ms 262144 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -