Submission #993733

# Submission time Handle Problem Language Result Execution time Memory
993733 2024-06-06T10:41:51 Z VMaksimoski008 Bigger segments (IZhO19_segments) C++17
27 / 100
1500 ms 71004 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[i-1] >= pref[i-1] - pref[k-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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 26 ms 2396 KB Output is correct
17 Correct 27 ms 2428 KB Output is correct
18 Correct 28 ms 2392 KB Output is correct
19 Correct 22 ms 2392 KB Output is correct
20 Correct 25 ms 2440 KB Output is correct
21 Correct 26 ms 2436 KB Output is correct
22 Correct 13 ms 1624 KB Output is correct
23 Correct 6 ms 1116 KB Output is correct
24 Correct 26 ms 2396 KB Output is correct
25 Correct 32 ms 2392 KB Output is correct
26 Correct 31 ms 2396 KB Output is correct
27 Correct 21 ms 2396 KB Output is correct
28 Correct 27 ms 2392 KB Output is correct
29 Correct 27 ms 2396 KB Output is correct
30 Correct 25 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 26 ms 2396 KB Output is correct
17 Correct 27 ms 2428 KB Output is correct
18 Correct 28 ms 2392 KB Output is correct
19 Correct 22 ms 2392 KB Output is correct
20 Correct 25 ms 2440 KB Output is correct
21 Correct 26 ms 2436 KB Output is correct
22 Correct 13 ms 1624 KB Output is correct
23 Correct 6 ms 1116 KB Output is correct
24 Correct 26 ms 2396 KB Output is correct
25 Correct 32 ms 2392 KB Output is correct
26 Correct 31 ms 2396 KB Output is correct
27 Correct 21 ms 2396 KB Output is correct
28 Correct 27 ms 2392 KB Output is correct
29 Correct 27 ms 2396 KB Output is correct
30 Correct 25 ms 2392 KB Output is correct
31 Execution timed out 1564 ms 71004 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 26 ms 2396 KB Output is correct
17 Correct 27 ms 2428 KB Output is correct
18 Correct 28 ms 2392 KB Output is correct
19 Correct 22 ms 2392 KB Output is correct
20 Correct 25 ms 2440 KB Output is correct
21 Correct 26 ms 2436 KB Output is correct
22 Correct 13 ms 1624 KB Output is correct
23 Correct 6 ms 1116 KB Output is correct
24 Correct 26 ms 2396 KB Output is correct
25 Correct 32 ms 2392 KB Output is correct
26 Correct 31 ms 2396 KB Output is correct
27 Correct 21 ms 2396 KB Output is correct
28 Correct 27 ms 2392 KB Output is correct
29 Correct 27 ms 2396 KB Output is correct
30 Correct 25 ms 2392 KB Output is correct
31 Execution timed out 1564 ms 71004 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 26 ms 2396 KB Output is correct
17 Correct 27 ms 2428 KB Output is correct
18 Correct 28 ms 2392 KB Output is correct
19 Correct 22 ms 2392 KB Output is correct
20 Correct 25 ms 2440 KB Output is correct
21 Correct 26 ms 2436 KB Output is correct
22 Correct 13 ms 1624 KB Output is correct
23 Correct 6 ms 1116 KB Output is correct
24 Correct 26 ms 2396 KB Output is correct
25 Correct 32 ms 2392 KB Output is correct
26 Correct 31 ms 2396 KB Output is correct
27 Correct 21 ms 2396 KB Output is correct
28 Correct 27 ms 2392 KB Output is correct
29 Correct 27 ms 2396 KB Output is correct
30 Correct 25 ms 2392 KB Output is correct
31 Execution timed out 1564 ms 71004 KB Time limit exceeded
32 Halted 0 ms 0 KB -