Submission #609098

# Submission time Handle Problem Language Result Execution time Memory
609098 2022-07-27T12:14:33 Z Redhood Popeala (CEOI16_popeala) C++14
0 / 100
6 ms 1492 KB
#include <bits/stdc++.h>
#define fi first
#define se second

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;


typedef long long ll;
typedef long double ld;

const int inf = 2e9 + 1;
const int T = 20'0;
const int S = 51;
int dp[T][S];

int main()
{
    int t, n , s;
    cin >> n >> t >> s;
    vector < int > score(t);
    for(auto &i : score)
    cin >> i;


    vector < string > capble;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        capble.pb(s);
    }

    vector<int>pref(t);

    pref[0] = score[0];
    for(int i = 1; i < t; ++i){
        pref[i] = pref[i - 1] + score[i];
    }

    auto get = [&](int l , int r){
        assert(l != -1);
        return pref[r] - (l == 0 ? 0 : pref[l - 1]);
    };

    int left[n][t];

    for(int i = 0;i < n; ++i){
        int cur = -1;
        for(int j = 0; j < t; ++j){
            if(capble[i][j] == '0')
                cur = j;
            left[i][j] = cur;
        }

    }

    /// yo
    for(int i = 0; i < T; ++i)
        fill(dp[i] , dp[i] + S , inf);
    for(int i = 0; i < t; ++i){
        /// yo
//        cerr << "there " << i << endl;
        vector<int>ps;
        for(int j = 0; j < n; ++j){
            ps.pb(left[j][i]);
        }
        sort(rall(ps));

        for(int k = 1; k <= s; ++k){
            if(i - 1 >= 0){
                dp[i][k] = min(dp[i][k] , dp[i - 1][k] + score[i]);
            }
            int ptr = 0;
            int cnt = n;
            while(ptr < sz(ps)){
                if(ps[ptr] == -1)
                    break;
                cnt--;
                while(ptr + 1 < sz(ps) && ps[ptr] == ps[ptr+1]){
                    cnt--;
                    ptr++;
                }
                assert(ptr<sz(ps));
                if(ps[ptr]-1 >= 0 && k - 1 >= 0){
//                    cout << " WHATA FUK " << ps[ptr]-1 << ' ' << k-1 << endl;
                    dp[i][k] = min((ll)dp[i][k] , (ll)dp[ps[ptr]-1][k-1] + 1ll * cnt * get(ps[ptr], i));
                }

                ptr++;
            }
            if(k == 1){
                dp[i][1] = min((ll)dp[i][1], 1ll*cnt*get(0,i));
            }


        }
//        cout << "LOL " << i << '\n';
//        for(int j = 1; j <= 3; ++j)
//            cout << dp[i][j] << ' ';
//        cout << '\n';
    }

    for(int k = 1; k <= s; ++k)
        cout << dp[t - 1][k] << ' ';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1492 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -