Submission #176012

# Submission time Handle Problem Language Result Execution time Memory
176012 2020-01-07T14:55:16 Z istlemin Bigger segments (IZhO19_segments) C++14
27 / 100
1500 ms 70904 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int main() {
    //cin.sync_with_stdio(0); cin.tie(0);
    //cin.exceptions(cin.failbit);
    ll n;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];

    vector<vi> dp(n,vi(n+1,-1e9));

    rep(i,0,n+1) dp[0][i] = 0;

    rep(i,1,n){
        ll sum = 0;
        rep(j,i,n){
            sum += a[j];
            ll sum2 = 0;
            for(ll k = i-1;k>=0;k--){
                sum2 += a[k];
                if(sum2>sum) break;
                dp[i][j] = max(dp[i][j],dp[k][i-1]+1);
            }
        }
    }

    //rep(i,0,n) {
    //    rep(j,0,n) printf("%10d ",dp[i][j]);
    //    printf("\n");
    //}
    ll ans = 0;
    rep(i,0,n) ans = max(ans,dp[i][n-1]);
    cout<<ans+1<<endl; 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 22 ms 2296 KB Output is correct
17 Correct 22 ms 2296 KB Output is correct
18 Correct 22 ms 2296 KB Output is correct
19 Correct 17 ms 2296 KB Output is correct
20 Correct 23 ms 2296 KB Output is correct
21 Correct 23 ms 2296 KB Output is correct
22 Correct 13 ms 1632 KB Output is correct
23 Correct 7 ms 1016 KB Output is correct
24 Correct 22 ms 2296 KB Output is correct
25 Correct 23 ms 2296 KB Output is correct
26 Correct 31 ms 2296 KB Output is correct
27 Correct 15 ms 2264 KB Output is correct
28 Correct 28 ms 2296 KB Output is correct
29 Correct 27 ms 2296 KB Output is correct
30 Correct 22 ms 2344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 22 ms 2296 KB Output is correct
17 Correct 22 ms 2296 KB Output is correct
18 Correct 22 ms 2296 KB Output is correct
19 Correct 17 ms 2296 KB Output is correct
20 Correct 23 ms 2296 KB Output is correct
21 Correct 23 ms 2296 KB Output is correct
22 Correct 13 ms 1632 KB Output is correct
23 Correct 7 ms 1016 KB Output is correct
24 Correct 22 ms 2296 KB Output is correct
25 Correct 23 ms 2296 KB Output is correct
26 Correct 31 ms 2296 KB Output is correct
27 Correct 15 ms 2264 KB Output is correct
28 Correct 28 ms 2296 KB Output is correct
29 Correct 27 ms 2296 KB Output is correct
30 Correct 22 ms 2344 KB Output is correct
31 Execution timed out 1525 ms 70904 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 22 ms 2296 KB Output is correct
17 Correct 22 ms 2296 KB Output is correct
18 Correct 22 ms 2296 KB Output is correct
19 Correct 17 ms 2296 KB Output is correct
20 Correct 23 ms 2296 KB Output is correct
21 Correct 23 ms 2296 KB Output is correct
22 Correct 13 ms 1632 KB Output is correct
23 Correct 7 ms 1016 KB Output is correct
24 Correct 22 ms 2296 KB Output is correct
25 Correct 23 ms 2296 KB Output is correct
26 Correct 31 ms 2296 KB Output is correct
27 Correct 15 ms 2264 KB Output is correct
28 Correct 28 ms 2296 KB Output is correct
29 Correct 27 ms 2296 KB Output is correct
30 Correct 22 ms 2344 KB Output is correct
31 Execution timed out 1525 ms 70904 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 22 ms 2296 KB Output is correct
17 Correct 22 ms 2296 KB Output is correct
18 Correct 22 ms 2296 KB Output is correct
19 Correct 17 ms 2296 KB Output is correct
20 Correct 23 ms 2296 KB Output is correct
21 Correct 23 ms 2296 KB Output is correct
22 Correct 13 ms 1632 KB Output is correct
23 Correct 7 ms 1016 KB Output is correct
24 Correct 22 ms 2296 KB Output is correct
25 Correct 23 ms 2296 KB Output is correct
26 Correct 31 ms 2296 KB Output is correct
27 Correct 15 ms 2264 KB Output is correct
28 Correct 28 ms 2296 KB Output is correct
29 Correct 27 ms 2296 KB Output is correct
30 Correct 22 ms 2344 KB Output is correct
31 Execution timed out 1525 ms 70904 KB Time limit exceeded
32 Halted 0 ms 0 KB -