답안 #567379

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567379 2022-05-23T11:32:56 Z piOOE 조교 (CEOI16_popeala) C++17
0 / 100
349 ms 2272 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)
#define sz(x) ((int)size(x))
#define trace(x) cout << #x << ": " << (x) << endl;

typedef long long ll;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int S = 51, N = 51, T = 20001;
const ll infL = 3e18;

int L[S][T], R[S][T], W[S][T], s, n, t, A[T];
ll dp[S][T];

bool solved[N][T];

ll weight(int l, int r) {
    ll every = 0;
    for (int i = 0; i < n; ++i) {
        ll sum = 0;
        bool ok = true;
        for (int j = l; j <= r; ++j) {
            if (!solved[i][j]) {
                ok = false;
                break;
            }
            sum += A[j];
        }
        every += ok ? sum : 0;
    }
    return every;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> t >> s;
    for (int i = 0; i < t; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < n; ++i) {
        string ss;
        cin >> ss;
        for (int j = 0; j < t; ++j) {
            solved[i][j] = ss[j] == '1';
        }
    }
    for (int i = 1; i <= t; ++i) {
        for (int cnt = 1; cnt <= s; ++cnt) {
            dp[i][cnt] = infL;
            for (int j = i - 1; j >= cnt - 1; --j) {
                dp[i][cnt] = min(dp[i][cnt], dp[j][cnt - 1] + weight(j, i - 1));
            }
            if (i == t) {
                cout << dp[i][cnt] << '\n';
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 6 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 347 ms 2052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 349 ms 2272 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 6 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -