Submission #154677

# Submission time Handle Problem Language Result Execution time Memory
154677 2019-09-23T13:44:01 Z hentai_lover Bigger segments (IZhO19_segments) C++14
37 / 100
387 ms 73592 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define lft(x) x * 2
#define rgt(x) x * 2 + 1

#define tm hui_pizda
#define ft first
#define sd second
#define pb push_back
#define pf push_front
#define sz size()
#define cnt continue
#define m_p make_pair
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
#define rf(i, r, l) for(int i = r; i >= l; -- i)
#pragma GCC optimize(-O3)
#pragma GCC optimize(Ofast)
#pragma GCC optimize("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using _set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpi;
typedef vector <pll> vpl;

mt19937_64 rnd(time(NULL));

const ll N = 3100;
const ll mtrxN = 10;
const ll oo = 1e18 + 10;
//const ll oo = 228;
const ll B = 500;
const ll mod = 1e9 + 7;

struct mtrx{
    ll m[mtrxN][mtrxN] = {};
};
mtrx mtrx_mult(mtrx a, mtrx b){
    mtrx c;
    fr(i, 0, mtrxN - 1){
        fr(j, 0, mtrxN - 1){
            ll sum = 0;
            fr(x, 0, mtrxN - 1){
                sum += a.m[i][x] * b.m[x][j];
                sum %= mod;
            }
            c.m[i][j] = sum;
        }
    }
    return c;
}
mtrx mtrx_pow(mtrx a, ll n){
    mtrx res;
    fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
    n --;
    while(n){
        if(n&1)res = mtrx_mult(res, a);
        a = mtrx_mult(a, a);
        n >>= 1;
    }
    return res;
}
ll _pow(ll a, ll n){
    ll r = 1;
    while(n){
        if(n&1)r = r * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return r;
}
ll div(ll x, ll y, ll md){
    return x * _pow(y, md - 2) % md;
}

ll a[N], p[N], dp[N][N];
ll n;

int main(){
    cin >> n;
    fr(i, 1, n)cin >> a[i], p[i] = p[i - 1] + a[i];
    fr(i, 1, n)fr(j, 1, n)dp[i][j] = oo;
    fr(i, 1, n)dp[i][1] = p[i];
    fr(i, 1, n - 1){
        fr(j, 1, n - 1){
            ll pos = lower_bound(p + 1, p + 1 + n, p[i] + dp[i][j]) - p;
            fr(x, 0, 10)dp[pos + x][j + 1] = min(dp[pos + x][j + 1], p[pos + x] - p[i]);
        }
    }
    ll ans = -1;
    fr(i, 1, n)fr(j, 1, n)if(dp[i][j] != oo)ans = max(ans, (ll)j);
    cout << ans;
    return 0;
}
/*
9 1 0
000000000
*/

Compilation message

segments.cpp:17:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(-O3)
                      ^
segments.cpp:18:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(Ofast)
                      ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 508 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 7 ms 528 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 508 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 7 ms 528 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 10 ms 4348 KB Output is correct
17 Correct 13 ms 4348 KB Output is correct
18 Correct 14 ms 4344 KB Output is correct
19 Correct 14 ms 4472 KB Output is correct
20 Correct 14 ms 4472 KB Output is correct
21 Correct 14 ms 4472 KB Output is correct
22 Correct 10 ms 3192 KB Output is correct
23 Correct 8 ms 2296 KB Output is correct
24 Correct 13 ms 4344 KB Output is correct
25 Correct 14 ms 4472 KB Output is correct
26 Correct 13 ms 4344 KB Output is correct
27 Correct 13 ms 4472 KB Output is correct
28 Correct 14 ms 4472 KB Output is correct
29 Correct 13 ms 4344 KB Output is correct
30 Correct 13 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 508 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 7 ms 528 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 10 ms 4348 KB Output is correct
17 Correct 13 ms 4348 KB Output is correct
18 Correct 14 ms 4344 KB Output is correct
19 Correct 14 ms 4472 KB Output is correct
20 Correct 14 ms 4472 KB Output is correct
21 Correct 14 ms 4472 KB Output is correct
22 Correct 10 ms 3192 KB Output is correct
23 Correct 8 ms 2296 KB Output is correct
24 Correct 13 ms 4344 KB Output is correct
25 Correct 14 ms 4472 KB Output is correct
26 Correct 13 ms 4344 KB Output is correct
27 Correct 13 ms 4472 KB Output is correct
28 Correct 14 ms 4472 KB Output is correct
29 Correct 13 ms 4344 KB Output is correct
30 Correct 13 ms 4472 KB Output is correct
31 Correct 372 ms 73532 KB Output is correct
32 Correct 381 ms 73576 KB Output is correct
33 Correct 371 ms 73512 KB Output is correct
34 Correct 366 ms 73464 KB Output is correct
35 Correct 362 ms 73464 KB Output is correct
36 Correct 387 ms 73520 KB Output is correct
37 Correct 267 ms 59640 KB Output is correct
38 Correct 168 ms 39928 KB Output is correct
39 Correct 372 ms 73496 KB Output is correct
40 Correct 374 ms 73512 KB Output is correct
41 Correct 353 ms 73464 KB Output is correct
42 Correct 384 ms 73492 KB Output is correct
43 Correct 369 ms 73592 KB Output is correct
44 Correct 355 ms 73592 KB Output is correct
45 Correct 358 ms 73496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 508 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 7 ms 528 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 10 ms 4348 KB Output is correct
17 Correct 13 ms 4348 KB Output is correct
18 Correct 14 ms 4344 KB Output is correct
19 Correct 14 ms 4472 KB Output is correct
20 Correct 14 ms 4472 KB Output is correct
21 Correct 14 ms 4472 KB Output is correct
22 Correct 10 ms 3192 KB Output is correct
23 Correct 8 ms 2296 KB Output is correct
24 Correct 13 ms 4344 KB Output is correct
25 Correct 14 ms 4472 KB Output is correct
26 Correct 13 ms 4344 KB Output is correct
27 Correct 13 ms 4472 KB Output is correct
28 Correct 14 ms 4472 KB Output is correct
29 Correct 13 ms 4344 KB Output is correct
30 Correct 13 ms 4472 KB Output is correct
31 Correct 372 ms 73532 KB Output is correct
32 Correct 381 ms 73576 KB Output is correct
33 Correct 371 ms 73512 KB Output is correct
34 Correct 366 ms 73464 KB Output is correct
35 Correct 362 ms 73464 KB Output is correct
36 Correct 387 ms 73520 KB Output is correct
37 Correct 267 ms 59640 KB Output is correct
38 Correct 168 ms 39928 KB Output is correct
39 Correct 372 ms 73496 KB Output is correct
40 Correct 374 ms 73512 KB Output is correct
41 Correct 353 ms 73464 KB Output is correct
42 Correct 384 ms 73492 KB Output is correct
43 Correct 369 ms 73592 KB Output is correct
44 Correct 355 ms 73592 KB Output is correct
45 Correct 358 ms 73496 KB Output is correct
46 Runtime error 8 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 508 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 7 ms 528 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 10 ms 4348 KB Output is correct
17 Correct 13 ms 4348 KB Output is correct
18 Correct 14 ms 4344 KB Output is correct
19 Correct 14 ms 4472 KB Output is correct
20 Correct 14 ms 4472 KB Output is correct
21 Correct 14 ms 4472 KB Output is correct
22 Correct 10 ms 3192 KB Output is correct
23 Correct 8 ms 2296 KB Output is correct
24 Correct 13 ms 4344 KB Output is correct
25 Correct 14 ms 4472 KB Output is correct
26 Correct 13 ms 4344 KB Output is correct
27 Correct 13 ms 4472 KB Output is correct
28 Correct 14 ms 4472 KB Output is correct
29 Correct 13 ms 4344 KB Output is correct
30 Correct 13 ms 4472 KB Output is correct
31 Correct 372 ms 73532 KB Output is correct
32 Correct 381 ms 73576 KB Output is correct
33 Correct 371 ms 73512 KB Output is correct
34 Correct 366 ms 73464 KB Output is correct
35 Correct 362 ms 73464 KB Output is correct
36 Correct 387 ms 73520 KB Output is correct
37 Correct 267 ms 59640 KB Output is correct
38 Correct 168 ms 39928 KB Output is correct
39 Correct 372 ms 73496 KB Output is correct
40 Correct 374 ms 73512 KB Output is correct
41 Correct 353 ms 73464 KB Output is correct
42 Correct 384 ms 73492 KB Output is correct
43 Correct 369 ms 73592 KB Output is correct
44 Correct 355 ms 73592 KB Output is correct
45 Correct 358 ms 73496 KB Output is correct
46 Runtime error 8 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Halted 0 ms 0 KB -