Submission #237398

# Submission time Handle Problem Language Result Execution time Memory
237398 2020-06-06T13:21:03 Z Sorting Popeala (CEOI16_popeala) C++14
0 / 100
45 ms 2424 KB
#include <bits/stdc++.h>

using namespace std;

const int mx_N = 50 + 3;
const int mx_S = 50 + 3;
const int mx_T = 2e4 + 3;

int n, t, s;
long long dp[mx_S][mx_T];
long long p[mx_T], a[mx_T][mx_N], b[mx_N];
string r[mx_N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> t >> s;

    for(int i = 0; i < t; ++i){
        cin >> p[i + 1];
        p[i + 1] += p[i];
    }

    for(int i = 0; i < n; ++i)
        cin >> r[i];

    for(int i = 0; i < t; ++i)
        for(int j = 0; j < n; ++j)
            a[i + 1][j] = (r[j][i] & 1) ? a[i][j] : i + 1;

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

    for(int i = 1; i <= n; ++i)
        dp[0][i] = INT_MAX;
    dp[0][0] = 0;
    
    for(int i = 1; i <= s; ++i){
        

        for(int j = 1; j <= t; ++j){
            dp[i][j] = INT_MAX;
            for(int k = 0; k <= n; ++k)
                b[k] = INT_MAX;
            for(int k = 0; k <= n; ++k){
                for(int l = a[j - 1][k]; l < a[j][k]; ++l)
                    b[k] = min(dp[i - 1][l] - p[l] * k, b[k]);
                dp[i][j] = min(b[k] + p[j] * k, dp[i][j]);
            }
            //cout << dp[i][j] << " dp[" << i << "][" << j << "]\n";  
        }
        dp[i][0] = INT_MAX;

        cout << dp[i][t] << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 2424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct