Submission #997924

# Submission time Handle Problem Language Result Execution time Memory
997924 2024-06-13T06:44:05 Z piOOE Cigle (COI21_cigle) C++17
0 / 100
2 ms 2396 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    vector dp(n, vector<int>(n + 1)), pref(dp);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            pref[i][j + 1] = max(pref[i][j], dp[i][j]);
        }
        if (i == 7) {
            cout << "here!" << endl;
        }
        int bal = 0, mx = 0, cnt = -1;
        for (int k = i + 1, j = i; k < n; ++k) {
            int add = 0;
            if (bal == 0) {
                add = 1;
                cnt += 1;
            }
            bal += d[k];
            while (j >= 0 && bal - d[j] >= 0) {
                mx = max(mx, cnt + dp[i][j] - add * (j == i));
                bal -= d[j--];
            }
            dp[k][i + 1] = mx;
            if (j >= 0) {
                dp[k][i + 1] = max(dp[k][i + 1], cnt + pref[i][j + 1]);
            }
        }
    }

//    cout << dp[7][2] << endl;

    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -