답안 #164070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164070 2019-11-17T09:18:20 Z dandrozavr Bigger segments (IZhO19_segments) C++14
27 / 100
1500 ms 70868 KB
/*
Uruchamiamy samolot zwiadowczy ( + 500% do wzlamaniej )

/▄/  /█/  /🔥/   /▐/   /▌/ /▀/ /░/ /◐ / choose  your  own style

***IT'S OUR LONG WAY TO THE OIILLLL***


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░███░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░█▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▀██████████████████████████████████████████████████
░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄████▄████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████
░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████░░░░░░░░░░░░░░░
*/



//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <bits/stdc++.h>

using namespace std;
#include <ext/pb_ds/detail/standard_policies.hpp>'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;template <typename T> using ordered_set = tree <T, null_type, less< T >, rb_tree_tag,tree_order_statistics_node_update>;

#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair < ll , int >
#define pipii pair< int, pair < int , int > >
#define siz(n) (int)(n.size())
#define TIME 1.0 * clock() / CLOCKS_PER_SEC
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int inf=1e9 + 7;
const ll inf18=1e18 + 7;
const int N=1e6 + 7;
const int MN = 2097152;
const int M = 1e9 + 7;


int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
    #ifdef Estb_probitie
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    ll pref[n];
    pref[0] = a[0];
    for (int i = 1; i < n; ++i)
        pref[i] = pref[i - 1] + a[i];

    ll dp[n][n + 1];
    for (int i = 0; i < n; ++i)
        fill(dp[i], dp[i] + n + 1, 1e17);

    dp[0][1] = a[0];

    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            dp[i][j] = min(dp[i][j], a[i] + dp[i - 1][j]);

            if (j > 1)
                for (int k = 0; k < i; ++k)
                if (pref[i] - pref[k] >= dp[k][j - 1])
                {
                    dp[i][j] = min(dp[i][j], pref[i] - pref[k]);
                }
//            cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
//        cout<<endl;
    }

    int ans = 0;
    for (int j = 1; j <= n; ++j)
        if (dp[n - 1][j] < 1e16)
        {
            ans = j;
        }
    cout << ans;
}

Compilation message

segments.cpp:35:50: warning: missing terminating ' character
 #include <ext/pb_ds/detail/standard_policies.hpp>'
                                                  ^
segments.cpp:35:50: warning: extra tokens at end of #include directive
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 296 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 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 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 296 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 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 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 139 ms 2424 KB Output is correct
17 Correct 138 ms 2388 KB Output is correct
18 Correct 138 ms 2296 KB Output is correct
19 Correct 148 ms 2296 KB Output is correct
20 Correct 163 ms 2356 KB Output is correct
21 Correct 135 ms 2296 KB Output is correct
22 Correct 70 ms 1528 KB Output is correct
23 Correct 30 ms 1024 KB Output is correct
24 Correct 143 ms 2344 KB Output is correct
25 Correct 136 ms 2296 KB Output is correct
26 Correct 160 ms 2296 KB Output is correct
27 Correct 141 ms 2296 KB Output is correct
28 Correct 141 ms 2424 KB Output is correct
29 Correct 156 ms 2296 KB Output is correct
30 Correct 159 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 296 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 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 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 139 ms 2424 KB Output is correct
17 Correct 138 ms 2388 KB Output is correct
18 Correct 138 ms 2296 KB Output is correct
19 Correct 148 ms 2296 KB Output is correct
20 Correct 163 ms 2356 KB Output is correct
21 Correct 135 ms 2296 KB Output is correct
22 Correct 70 ms 1528 KB Output is correct
23 Correct 30 ms 1024 KB Output is correct
24 Correct 143 ms 2344 KB Output is correct
25 Correct 136 ms 2296 KB Output is correct
26 Correct 160 ms 2296 KB Output is correct
27 Correct 141 ms 2296 KB Output is correct
28 Correct 141 ms 2424 KB Output is correct
29 Correct 156 ms 2296 KB Output is correct
30 Correct 159 ms 2384 KB Output is correct
31 Execution timed out 1558 ms 70868 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 296 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 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 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 139 ms 2424 KB Output is correct
17 Correct 138 ms 2388 KB Output is correct
18 Correct 138 ms 2296 KB Output is correct
19 Correct 148 ms 2296 KB Output is correct
20 Correct 163 ms 2356 KB Output is correct
21 Correct 135 ms 2296 KB Output is correct
22 Correct 70 ms 1528 KB Output is correct
23 Correct 30 ms 1024 KB Output is correct
24 Correct 143 ms 2344 KB Output is correct
25 Correct 136 ms 2296 KB Output is correct
26 Correct 160 ms 2296 KB Output is correct
27 Correct 141 ms 2296 KB Output is correct
28 Correct 141 ms 2424 KB Output is correct
29 Correct 156 ms 2296 KB Output is correct
30 Correct 159 ms 2384 KB Output is correct
31 Execution timed out 1558 ms 70868 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 296 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 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 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 139 ms 2424 KB Output is correct
17 Correct 138 ms 2388 KB Output is correct
18 Correct 138 ms 2296 KB Output is correct
19 Correct 148 ms 2296 KB Output is correct
20 Correct 163 ms 2356 KB Output is correct
21 Correct 135 ms 2296 KB Output is correct
22 Correct 70 ms 1528 KB Output is correct
23 Correct 30 ms 1024 KB Output is correct
24 Correct 143 ms 2344 KB Output is correct
25 Correct 136 ms 2296 KB Output is correct
26 Correct 160 ms 2296 KB Output is correct
27 Correct 141 ms 2296 KB Output is correct
28 Correct 141 ms 2424 KB Output is correct
29 Correct 156 ms 2296 KB Output is correct
30 Correct 159 ms 2384 KB Output is correct
31 Execution timed out 1558 ms 70868 KB Time limit exceeded
32 Halted 0 ms 0 KB -