답안 #993732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993732 2024-06-06T10:41:15 Z VMaksimoski008 Bigger segments (IZhO19_segments) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);

    int n;
    cin >> n;

    vector<int> v(n+1);
    vector<ll> pref(n+1);
    for(int i=1; i<=n; i++) {
        cin >> v[i];
        pref[i] = pref[i-1] + v[i];
    }

    int dp[n+1][n+1];
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++) dp[i][j] = -1e9;
    for(int i=1; i<=n; i++) dp[1][i] = 1;

    for(int i=2; i<=n; i++)
        for(int j=i; j<=n; j++)
            for(int k=1; k<i; k++)
                if(pref[j] - pref[k-1] >= 2 * pref[i-1]) dp[i][j] = max(dp[i][j], dp[k][i-1] + 1);

    int ans = 0;
    for(int i=1; i<=n; i++) ans = max(ans, dp[i][n]);
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -