Submission #537014

# Submission time Handle Problem Language Result Execution time Memory
537014 2022-03-14T09:32:40 Z squiddy Popeala (CEOI16_popeala) C++14
8 / 100
2000 ms 54872 KB
#include <bits/stdc++.h>
#define fast_input ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;
#define ii pair<int, int>
#define iii pair<int, ii>
#define ll long long
#define ull unsigned long long
#define pq priority_queue
#define FOR(v, s, e) for (int v = s; v < e; v++)
#define FOR_REV(v, s, e) for (int v = e - 1; v >= s; v--)
#define make_ii(a, b) make_pair(a, b)
#define make_iii(a, b, c) make_pair(a, make_pair(b, c))
#define fi first
#define se second
//#define int long long

int n, t, s;
int points[505];
int results[55][505];
int memo[505][505][55];

int dp(int i, int start, int left) {
    if (i == t + 1 && left != 0) return 2000000001;
    if (i == t + 1 && left == 0) return 0;
    if (left == 0) return 2000000001;
    if (memo[i][start][left] != 0) return memo[i][start][left];
    int score = 0, no_ac = 0;
    FOR(j, 0, n) {
        no_ac += (results[j][i] - results[j][start - 1] == i - start + 1);
    }
    score = no_ac * (points[i] - points[start - 1]);
    //cout << i << start << no_ac << '\n';
    return memo[i][start][left] = min(
        dp(i + 1, i + 1, left - 1) + score,
        dp(i + 1, start, left)
    );
}

int32_t main() {
    fast_input;
    cin >> n >> t >> s;
    FOR(i, 1, t + 1) {
        int x;
        cin >> x;
        points[i] = x + points[i - 1];
    }
    FOR(i, 0, n) {
        string cs;
        cin >> cs;
        FOR(j, 1, t + 1) {
            results[i][j] = cs[j - 1] + results[i][j - 1] - '0';
        }
    }
    FOR(ck, 1, s + 1) {
        cout << dp(1, 1, ck) << '\n';
        FOR(i, 0, t) {
            FOR(j, 0, t) {
                FOR(k, 0, s) {
                    memo[i][j][k] = 0;
                }
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 4 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 54872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 4 ms 852 KB Output is correct
3 Execution timed out 2088 ms 54872 KB Time limit exceeded
4 Halted 0 ms 0 KB -