Submission #444197

# Submission time Handle Problem Language Result Execution time Memory
444197 2021-07-13T10:29:04 Z prvocislo Popeala (CEOI16_popeala) C++17
0 / 100
1 ms 588 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int inf = 2e9 + 5;
void upd(int &a, int b) { a = min(a, b); }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, s;
    cin >> n >> t >> s;
    vector<int> pf(n+1, 0);
    for (int i = 1, x; i <= t; i++) cin >> x, pf[i] = pf[i-1] + x;
    vector<vector<int> > h(t+1, vector<int>(n+1, 0));
    for (int i = 0; i < n; i++)
    {
        string s; cin >> s;
        for (int j = 1; j <= t; j++)
        {
            h[j][i] = h[j-1][i];
            if (s[j-1] == '0') h[j][i] = j;
        }
    }
    for (int i = 1; i <= t; i++)
    {
        h[i][n] = i;
        sort(h[i].begin(), h[i].end());
    }
    vector<vector<int> > dp(s+1, vector<int>(t+1, inf));
    dp[0][0] = 0;
    for (int i = 1; i <= s; i++)
    {
        vector<int> best(n+1, inf);
        for (int j = 1; j <= t; j++)
        {
            for (int k = 0; k <= n; k++) 
            {
                for (int l = h[j-1][k]; l < h[j][k]; l++)
                    upd(best[k], dp[i-1][l]-pf[l]*k);
                upd(dp[i][j], best[k]+pf[j]*k);
            }
        }
        cout << dp[i][t] << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6