Submission #341720

# Submission time Handle Problem Language Result Execution time Memory
341720 2020-12-30T15:55:16 Z phathnv Popeala (CEOI16_popeala) C++11
0 / 100
43 ms 1516 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int T = 20002;
const int N = 51;
const int S = 51;
const int INF = 2e9 + 10;

int n, t, s, p[T], dp[S][T], last[T][N], minVal[N];
string a[N];

void ReadInput(){
    cin >> n >> t >> s;
    for(int i = 1; i <= t; i++)
        cin >> p[i];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] = '*' + a[i];
    }
}

void Solve(){
    for(int i = 1; i <= t; i++)
        p[i] += p[i - 1];
    for(int i = 1; i <= t; i++)
        for(int j = 1; j <= n; j++)
            last[i][j] = (a[j][i] == '0'? i : last[i - 1][j]);

    for(int i = 1; i <= t; i++){
        last[i][0] = 0;
        sort(last[i], last[i] + 1 + n);
    }

    for(int i = 0; i <= s; i++)
        for(int j = 0; j <= t; j++)
            dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i = 1; i <= s; i++){
        for(int j = 0; j <= n; j++)
            minVal[j] = dp[i - 1][0];
        for(int j = 1; j <= t; j++)
            for(int k = 0; k <= n; k++){
                for(int l = last[j - 1][k]; l < last[j][k]; l++)
                    minVal[k] = min(minVal[k], dp[i - 1][l] - p[l] * k);
                dp[i][j] = min(dp[i][j], minVal[k] + p[j] * k);
            }
    }

    for(int i = 1; i <= s; i++)
        cout << dp[i][t] << '\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ReadInput();
    Solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 492 KB Output isn't correct