Submission #164076

# Submission time Handle Problem Language Result Execution time Memory
164076 2019-11-17T09:47:39 Z dandrozavr Bigger segments (IZhO19_segments) C++14
13 / 100
1494 ms 4472 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;

ll dp[3001][3001];

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];

    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)
    {
        bool byl = 1;
        int cc = (1.5 * CLOCKS_PER_SEC - clock()) / (n - i + 1);
        int zn = clock();

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

            if (j > 1 && byl)
            {
                byl = 0;
                for (int k = i - 1; k >= 0; --k)
                {
                    if (clock() > cc + zn + 10) break;
                    if (pref[i] - pref[k] >= dp[k][j - 1])
                    {
                        dp[i][j] = min(dp[i][j], pref[i] - pref[k]);
                        byl = 1;
    //                    cout<<i<<" "<<k<<endl;
                        break;
                    }
                }
//            cout<<endl;
            }
            if (dp[i][j] >= 1e17) break;
        }
//        if (i % 100 == 0)
//        cerr<<"i = "<<i<<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
# Verdict Execution time Memory Grader output
1 Correct 3 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 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 424 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 424 KB Output is correct
14 Correct 3 ms 552 KB Output is correct
15 Correct 10 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 424 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 424 KB Output is correct
14 Correct 3 ms 552 KB Output is correct
15 Correct 10 ms 504 KB Output is correct
16 Correct 126 ms 4344 KB Output is correct
17 Correct 536 ms 4472 KB Output is correct
18 Correct 628 ms 4412 KB Output is correct
19 Incorrect 1494 ms 4472 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 424 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 424 KB Output is correct
14 Correct 3 ms 552 KB Output is correct
15 Correct 10 ms 504 KB Output is correct
16 Correct 126 ms 4344 KB Output is correct
17 Correct 536 ms 4472 KB Output is correct
18 Correct 628 ms 4412 KB Output is correct
19 Incorrect 1494 ms 4472 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 424 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 424 KB Output is correct
14 Correct 3 ms 552 KB Output is correct
15 Correct 10 ms 504 KB Output is correct
16 Correct 126 ms 4344 KB Output is correct
17 Correct 536 ms 4472 KB Output is correct
18 Correct 628 ms 4412 KB Output is correct
19 Incorrect 1494 ms 4472 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 424 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 424 KB Output is correct
14 Correct 3 ms 552 KB Output is correct
15 Correct 10 ms 504 KB Output is correct
16 Correct 126 ms 4344 KB Output is correct
17 Correct 536 ms 4472 KB Output is correct
18 Correct 628 ms 4412 KB Output is correct
19 Incorrect 1494 ms 4472 KB Output isn't correct
20 Halted 0 ms 0 KB -