Submission #187347

# Submission time Handle Problem Language Result Execution time Memory
187347 2020-01-12T20:45:40 Z stefdasca Bigger segments (IZhO19_segments) C++14
100 / 100
462 ms 105236 KB
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int n, v[500002];
ll sp[500002];

set<pair<int, int> >s[500002];

int tri(int val, int pz, int pz2)
{
    ll sum = sp[pz2] - sp[pz - 1];
    int st = pz+1;
    int dr = n;
    int ans = -1;
    while(st <= dr)
    {
        int mid = (st + dr) / 2;
        if(sp[mid] - sp[pz2] >= sum)
            ans = mid, dr = mid - 1;
        else
            st = mid + 1;
    }
    return ans;
}
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    for(int i = 1; i <= n; ++i)
        sp[i] = sp[i-1] + v[i];
    for(int i = 1; i <= n; ++i)
    {
        s[i].insert({1, 1});
        int lst = 6969696;
        if(i == n)
        {
            cout << (*s[n].rbegin()).fi << '\n';
            return 0;
        }
        while(!s[i].empty())
        {
            pair<int, int> xx = *s[i].rbegin();
            s[i].erase(xx);
            if(xx.fi == lst)
                continue;
            s[i+1].insert(xx);
            int ans = tri(xx.fi, xx.se, i);
          //  cout << i << " " << ans << " " << xx.fi << " " << xx.se << '\n';
            if(ans != -1)
                s[ans].insert({xx.fi + 1, i + 1});
            if(lst != 6969696)
                break;
            lst = xx.fi;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23928 KB Output is correct
2 Correct 24 ms 23928 KB Output is correct
3 Correct 13 ms 23872 KB Output is correct
4 Correct 24 ms 23800 KB Output is correct
5 Correct 24 ms 23800 KB Output is correct
6 Correct 24 ms 23800 KB Output is correct
7 Correct 24 ms 23928 KB Output is correct
8 Correct 24 ms 23800 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 24 ms 23800 KB Output is correct
11 Correct 24 ms 23800 KB Output is correct
12 Correct 24 ms 24056 KB Output is correct
13 Correct 24 ms 23928 KB Output is correct
14 Correct 28 ms 23928 KB Output is correct
15 Correct 26 ms 23864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23928 KB Output is correct
2 Correct 24 ms 23928 KB Output is correct
3 Correct 13 ms 23872 KB Output is correct
4 Correct 24 ms 23800 KB Output is correct
5 Correct 24 ms 23800 KB Output is correct
6 Correct 24 ms 23800 KB Output is correct
7 Correct 24 ms 23928 KB Output is correct
8 Correct 24 ms 23800 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 24 ms 23800 KB Output is correct
11 Correct 24 ms 23800 KB Output is correct
12 Correct 24 ms 24056 KB Output is correct
13 Correct 24 ms 23928 KB Output is correct
14 Correct 28 ms 23928 KB Output is correct
15 Correct 26 ms 23864 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 24 ms 23920 KB Output is correct
18 Correct 24 ms 23928 KB Output is correct
19 Correct 24 ms 23928 KB Output is correct
20 Correct 24 ms 23928 KB Output is correct
21 Correct 26 ms 23868 KB Output is correct
22 Correct 24 ms 23928 KB Output is correct
23 Correct 24 ms 23928 KB Output is correct
24 Correct 24 ms 23928 KB Output is correct
25 Correct 24 ms 23820 KB Output is correct
26 Correct 23 ms 23848 KB Output is correct
27 Correct 24 ms 23928 KB Output is correct
28 Correct 24 ms 23928 KB Output is correct
29 Correct 24 ms 23928 KB Output is correct
30 Correct 24 ms 23928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23928 KB Output is correct
2 Correct 24 ms 23928 KB Output is correct
3 Correct 13 ms 23872 KB Output is correct
4 Correct 24 ms 23800 KB Output is correct
5 Correct 24 ms 23800 KB Output is correct
6 Correct 24 ms 23800 KB Output is correct
7 Correct 24 ms 23928 KB Output is correct
8 Correct 24 ms 23800 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 24 ms 23800 KB Output is correct
11 Correct 24 ms 23800 KB Output is correct
12 Correct 24 ms 24056 KB Output is correct
13 Correct 24 ms 23928 KB Output is correct
14 Correct 28 ms 23928 KB Output is correct
15 Correct 26 ms 23864 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 24 ms 23920 KB Output is correct
18 Correct 24 ms 23928 KB Output is correct
19 Correct 24 ms 23928 KB Output is correct
20 Correct 24 ms 23928 KB Output is correct
21 Correct 26 ms 23868 KB Output is correct
22 Correct 24 ms 23928 KB Output is correct
23 Correct 24 ms 23928 KB Output is correct
24 Correct 24 ms 23928 KB Output is correct
25 Correct 24 ms 23820 KB Output is correct
26 Correct 23 ms 23848 KB Output is correct
27 Correct 24 ms 23928 KB Output is correct
28 Correct 24 ms 23928 KB Output is correct
29 Correct 24 ms 23928 KB Output is correct
30 Correct 24 ms 23928 KB Output is correct
31 Correct 24 ms 23928 KB Output is correct
32 Correct 26 ms 24184 KB Output is correct
33 Correct 27 ms 24312 KB Output is correct
34 Correct 26 ms 24148 KB Output is correct
35 Correct 26 ms 24312 KB Output is correct
36 Correct 27 ms 24312 KB Output is correct
37 Correct 26 ms 24184 KB Output is correct
38 Correct 29 ms 24112 KB Output is correct
39 Correct 29 ms 24312 KB Output is correct
40 Correct 27 ms 24184 KB Output is correct
41 Correct 26 ms 24312 KB Output is correct
42 Correct 25 ms 24312 KB Output is correct
43 Correct 27 ms 24184 KB Output is correct
44 Correct 26 ms 24312 KB Output is correct
45 Correct 25 ms 24312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23928 KB Output is correct
2 Correct 24 ms 23928 KB Output is correct
3 Correct 13 ms 23872 KB Output is correct
4 Correct 24 ms 23800 KB Output is correct
5 Correct 24 ms 23800 KB Output is correct
6 Correct 24 ms 23800 KB Output is correct
7 Correct 24 ms 23928 KB Output is correct
8 Correct 24 ms 23800 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 24 ms 23800 KB Output is correct
11 Correct 24 ms 23800 KB Output is correct
12 Correct 24 ms 24056 KB Output is correct
13 Correct 24 ms 23928 KB Output is correct
14 Correct 28 ms 23928 KB Output is correct
15 Correct 26 ms 23864 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 24 ms 23920 KB Output is correct
18 Correct 24 ms 23928 KB Output is correct
19 Correct 24 ms 23928 KB Output is correct
20 Correct 24 ms 23928 KB Output is correct
21 Correct 26 ms 23868 KB Output is correct
22 Correct 24 ms 23928 KB Output is correct
23 Correct 24 ms 23928 KB Output is correct
24 Correct 24 ms 23928 KB Output is correct
25 Correct 24 ms 23820 KB Output is correct
26 Correct 23 ms 23848 KB Output is correct
27 Correct 24 ms 23928 KB Output is correct
28 Correct 24 ms 23928 KB Output is correct
29 Correct 24 ms 23928 KB Output is correct
30 Correct 24 ms 23928 KB Output is correct
31 Correct 24 ms 23928 KB Output is correct
32 Correct 26 ms 24184 KB Output is correct
33 Correct 27 ms 24312 KB Output is correct
34 Correct 26 ms 24148 KB Output is correct
35 Correct 26 ms 24312 KB Output is correct
36 Correct 27 ms 24312 KB Output is correct
37 Correct 26 ms 24184 KB Output is correct
38 Correct 29 ms 24112 KB Output is correct
39 Correct 29 ms 24312 KB Output is correct
40 Correct 27 ms 24184 KB Output is correct
41 Correct 26 ms 24312 KB Output is correct
42 Correct 25 ms 24312 KB Output is correct
43 Correct 27 ms 24184 KB Output is correct
44 Correct 26 ms 24312 KB Output is correct
45 Correct 25 ms 24312 KB Output is correct
46 Correct 44 ms 25464 KB Output is correct
47 Correct 102 ms 34424 KB Output is correct
48 Correct 111 ms 39672 KB Output is correct
49 Correct 91 ms 39120 KB Output is correct
50 Correct 91 ms 40056 KB Output is correct
51 Correct 122 ms 35448 KB Output is correct
52 Correct 74 ms 29724 KB Output is correct
53 Correct 50 ms 27384 KB Output is correct
54 Correct 106 ms 34808 KB Output is correct
55 Correct 108 ms 35584 KB Output is correct
56 Correct 85 ms 39544 KB Output is correct
57 Correct 98 ms 39472 KB Output is correct
58 Correct 97 ms 38620 KB Output is correct
59 Correct 90 ms 39616 KB Output is correct
60 Correct 87 ms 36856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23928 KB Output is correct
2 Correct 24 ms 23928 KB Output is correct
3 Correct 13 ms 23872 KB Output is correct
4 Correct 24 ms 23800 KB Output is correct
5 Correct 24 ms 23800 KB Output is correct
6 Correct 24 ms 23800 KB Output is correct
7 Correct 24 ms 23928 KB Output is correct
8 Correct 24 ms 23800 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 24 ms 23800 KB Output is correct
11 Correct 24 ms 23800 KB Output is correct
12 Correct 24 ms 24056 KB Output is correct
13 Correct 24 ms 23928 KB Output is correct
14 Correct 28 ms 23928 KB Output is correct
15 Correct 26 ms 23864 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 24 ms 23920 KB Output is correct
18 Correct 24 ms 23928 KB Output is correct
19 Correct 24 ms 23928 KB Output is correct
20 Correct 24 ms 23928 KB Output is correct
21 Correct 26 ms 23868 KB Output is correct
22 Correct 24 ms 23928 KB Output is correct
23 Correct 24 ms 23928 KB Output is correct
24 Correct 24 ms 23928 KB Output is correct
25 Correct 24 ms 23820 KB Output is correct
26 Correct 23 ms 23848 KB Output is correct
27 Correct 24 ms 23928 KB Output is correct
28 Correct 24 ms 23928 KB Output is correct
29 Correct 24 ms 23928 KB Output is correct
30 Correct 24 ms 23928 KB Output is correct
31 Correct 24 ms 23928 KB Output is correct
32 Correct 26 ms 24184 KB Output is correct
33 Correct 27 ms 24312 KB Output is correct
34 Correct 26 ms 24148 KB Output is correct
35 Correct 26 ms 24312 KB Output is correct
36 Correct 27 ms 24312 KB Output is correct
37 Correct 26 ms 24184 KB Output is correct
38 Correct 29 ms 24112 KB Output is correct
39 Correct 29 ms 24312 KB Output is correct
40 Correct 27 ms 24184 KB Output is correct
41 Correct 26 ms 24312 KB Output is correct
42 Correct 25 ms 24312 KB Output is correct
43 Correct 27 ms 24184 KB Output is correct
44 Correct 26 ms 24312 KB Output is correct
45 Correct 25 ms 24312 KB Output is correct
46 Correct 44 ms 25464 KB Output is correct
47 Correct 102 ms 34424 KB Output is correct
48 Correct 111 ms 39672 KB Output is correct
49 Correct 91 ms 39120 KB Output is correct
50 Correct 91 ms 40056 KB Output is correct
51 Correct 122 ms 35448 KB Output is correct
52 Correct 74 ms 29724 KB Output is correct
53 Correct 50 ms 27384 KB Output is correct
54 Correct 106 ms 34808 KB Output is correct
55 Correct 108 ms 35584 KB Output is correct
56 Correct 85 ms 39544 KB Output is correct
57 Correct 98 ms 39472 KB Output is correct
58 Correct 97 ms 38620 KB Output is correct
59 Correct 90 ms 39616 KB Output is correct
60 Correct 87 ms 36856 KB Output is correct
61 Correct 124 ms 31608 KB Output is correct
62 Correct 238 ms 43572 KB Output is correct
63 Correct 446 ms 68856 KB Output is correct
64 Correct 444 ms 104844 KB Output is correct
65 Correct 363 ms 105236 KB Output is correct
66 Correct 462 ms 82032 KB Output is correct
67 Correct 383 ms 70264 KB Output is correct
68 Correct 198 ms 47064 KB Output is correct
69 Correct 439 ms 78304 KB Output is correct
70 Correct 398 ms 81908 KB Output is correct
71 Correct 334 ms 102184 KB Output is correct
72 Correct 436 ms 102648 KB Output is correct
73 Correct 376 ms 103080 KB Output is correct
74 Correct 347 ms 103692 KB Output is correct
75 Correct 351 ms 98576 KB Output is correct