Submission #474705

# Submission time Handle Problem Language Result Execution time Memory
474705 2021-09-19T13:41:32 Z vipghn2003 Bigger segments (IZhO19_segments) C++14
100 / 100
194 ms 56008 KB
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=5e5+5;
int n;
ll a[N];
map<int,int>dp[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("Partition.INP","r",stdin);
    //freopen("Partition.OUT","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    //reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++) a[i]+=a[i-1];
    dp[1][0]=0;
    for(int i=1;i<n;i++)
    {
        while(dp[i].size()>1) dp[i].erase(dp[i].begin());
        for(auto&x:dp[i])
        {
            dp[i+1][x.fi]=max(dp[i+1][x.fi],x.se);
            int v=lower_bound(a+1,a+n+1,2*a[i]-a[x.se])-a;
            if(v<=n) dp[v][x.fi+1]=max(dp[v][x.fi+1],i);
        }
    }
    while(dp[n].size()>1) dp[n].erase(dp[n].begin());
    auto res=*dp[n].begin();
    cout<<res.fi+1;
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23800 KB Output is correct
2 Correct 16 ms 23728 KB Output is correct
3 Correct 15 ms 23724 KB Output is correct
4 Correct 15 ms 23756 KB Output is correct
5 Correct 16 ms 23756 KB Output is correct
6 Correct 15 ms 23808 KB Output is correct
7 Correct 14 ms 23732 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 15 ms 23764 KB Output is correct
10 Correct 15 ms 23692 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 16 ms 23804 KB Output is correct
13 Correct 15 ms 23804 KB Output is correct
14 Correct 15 ms 23704 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23800 KB Output is correct
2 Correct 16 ms 23728 KB Output is correct
3 Correct 15 ms 23724 KB Output is correct
4 Correct 15 ms 23756 KB Output is correct
5 Correct 16 ms 23756 KB Output is correct
6 Correct 15 ms 23808 KB Output is correct
7 Correct 14 ms 23732 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 15 ms 23764 KB Output is correct
10 Correct 15 ms 23692 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 16 ms 23804 KB Output is correct
13 Correct 15 ms 23804 KB Output is correct
14 Correct 15 ms 23704 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 16 ms 23724 KB Output is correct
17 Correct 15 ms 23800 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 17 ms 23728 KB Output is correct
21 Correct 15 ms 23756 KB Output is correct
22 Correct 15 ms 23756 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 15 ms 23828 KB Output is correct
25 Correct 17 ms 23832 KB Output is correct
26 Correct 15 ms 23804 KB Output is correct
27 Correct 15 ms 23756 KB Output is correct
28 Correct 17 ms 23800 KB Output is correct
29 Correct 15 ms 23756 KB Output is correct
30 Correct 17 ms 23756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23800 KB Output is correct
2 Correct 16 ms 23728 KB Output is correct
3 Correct 15 ms 23724 KB Output is correct
4 Correct 15 ms 23756 KB Output is correct
5 Correct 16 ms 23756 KB Output is correct
6 Correct 15 ms 23808 KB Output is correct
7 Correct 14 ms 23732 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 15 ms 23764 KB Output is correct
10 Correct 15 ms 23692 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 16 ms 23804 KB Output is correct
13 Correct 15 ms 23804 KB Output is correct
14 Correct 15 ms 23704 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 16 ms 23724 KB Output is correct
17 Correct 15 ms 23800 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 17 ms 23728 KB Output is correct
21 Correct 15 ms 23756 KB Output is correct
22 Correct 15 ms 23756 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 15 ms 23828 KB Output is correct
25 Correct 17 ms 23832 KB Output is correct
26 Correct 15 ms 23804 KB Output is correct
27 Correct 15 ms 23756 KB Output is correct
28 Correct 17 ms 23800 KB Output is correct
29 Correct 15 ms 23756 KB Output is correct
30 Correct 17 ms 23756 KB Output is correct
31 Correct 15 ms 23868 KB Output is correct
32 Correct 18 ms 23884 KB Output is correct
33 Correct 18 ms 23992 KB Output is correct
34 Correct 16 ms 23964 KB Output is correct
35 Correct 18 ms 23884 KB Output is correct
36 Correct 19 ms 23984 KB Output is correct
37 Correct 16 ms 23956 KB Output is correct
38 Correct 16 ms 23884 KB Output is correct
39 Correct 17 ms 23928 KB Output is correct
40 Correct 18 ms 23940 KB Output is correct
41 Correct 16 ms 23976 KB Output is correct
42 Correct 16 ms 23884 KB Output is correct
43 Correct 18 ms 24092 KB Output is correct
44 Correct 17 ms 23944 KB Output is correct
45 Correct 16 ms 23884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23800 KB Output is correct
2 Correct 16 ms 23728 KB Output is correct
3 Correct 15 ms 23724 KB Output is correct
4 Correct 15 ms 23756 KB Output is correct
5 Correct 16 ms 23756 KB Output is correct
6 Correct 15 ms 23808 KB Output is correct
7 Correct 14 ms 23732 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 15 ms 23764 KB Output is correct
10 Correct 15 ms 23692 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 16 ms 23804 KB Output is correct
13 Correct 15 ms 23804 KB Output is correct
14 Correct 15 ms 23704 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 16 ms 23724 KB Output is correct
17 Correct 15 ms 23800 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 17 ms 23728 KB Output is correct
21 Correct 15 ms 23756 KB Output is correct
22 Correct 15 ms 23756 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 15 ms 23828 KB Output is correct
25 Correct 17 ms 23832 KB Output is correct
26 Correct 15 ms 23804 KB Output is correct
27 Correct 15 ms 23756 KB Output is correct
28 Correct 17 ms 23800 KB Output is correct
29 Correct 15 ms 23756 KB Output is correct
30 Correct 17 ms 23756 KB Output is correct
31 Correct 15 ms 23868 KB Output is correct
32 Correct 18 ms 23884 KB Output is correct
33 Correct 18 ms 23992 KB Output is correct
34 Correct 16 ms 23964 KB Output is correct
35 Correct 18 ms 23884 KB Output is correct
36 Correct 19 ms 23984 KB Output is correct
37 Correct 16 ms 23956 KB Output is correct
38 Correct 16 ms 23884 KB Output is correct
39 Correct 17 ms 23928 KB Output is correct
40 Correct 18 ms 23940 KB Output is correct
41 Correct 16 ms 23976 KB Output is correct
42 Correct 16 ms 23884 KB Output is correct
43 Correct 18 ms 24092 KB Output is correct
44 Correct 17 ms 23944 KB Output is correct
45 Correct 16 ms 23884 KB Output is correct
46 Correct 34 ms 29568 KB Output is correct
47 Correct 41 ms 29732 KB Output is correct
48 Correct 48 ms 30080 KB Output is correct
49 Correct 48 ms 30148 KB Output is correct
50 Correct 50 ms 30172 KB Output is correct
51 Correct 44 ms 30220 KB Output is correct
52 Correct 35 ms 26920 KB Output is correct
53 Correct 24 ms 25668 KB Output is correct
54 Correct 41 ms 29468 KB Output is correct
55 Correct 44 ms 30208 KB Output is correct
56 Correct 48 ms 29628 KB Output is correct
57 Correct 40 ms 29664 KB Output is correct
58 Correct 42 ms 29636 KB Output is correct
59 Correct 46 ms 29760 KB Output is correct
60 Correct 43 ms 29808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23800 KB Output is correct
2 Correct 16 ms 23728 KB Output is correct
3 Correct 15 ms 23724 KB Output is correct
4 Correct 15 ms 23756 KB Output is correct
5 Correct 16 ms 23756 KB Output is correct
6 Correct 15 ms 23808 KB Output is correct
7 Correct 14 ms 23732 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 15 ms 23764 KB Output is correct
10 Correct 15 ms 23692 KB Output is correct
11 Correct 15 ms 23756 KB Output is correct
12 Correct 16 ms 23804 KB Output is correct
13 Correct 15 ms 23804 KB Output is correct
14 Correct 15 ms 23704 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 16 ms 23724 KB Output is correct
17 Correct 15 ms 23800 KB Output is correct
18 Correct 15 ms 23756 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 17 ms 23728 KB Output is correct
21 Correct 15 ms 23756 KB Output is correct
22 Correct 15 ms 23756 KB Output is correct
23 Correct 15 ms 23756 KB Output is correct
24 Correct 15 ms 23828 KB Output is correct
25 Correct 17 ms 23832 KB Output is correct
26 Correct 15 ms 23804 KB Output is correct
27 Correct 15 ms 23756 KB Output is correct
28 Correct 17 ms 23800 KB Output is correct
29 Correct 15 ms 23756 KB Output is correct
30 Correct 17 ms 23756 KB Output is correct
31 Correct 15 ms 23868 KB Output is correct
32 Correct 18 ms 23884 KB Output is correct
33 Correct 18 ms 23992 KB Output is correct
34 Correct 16 ms 23964 KB Output is correct
35 Correct 18 ms 23884 KB Output is correct
36 Correct 19 ms 23984 KB Output is correct
37 Correct 16 ms 23956 KB Output is correct
38 Correct 16 ms 23884 KB Output is correct
39 Correct 17 ms 23928 KB Output is correct
40 Correct 18 ms 23940 KB Output is correct
41 Correct 16 ms 23976 KB Output is correct
42 Correct 16 ms 23884 KB Output is correct
43 Correct 18 ms 24092 KB Output is correct
44 Correct 17 ms 23944 KB Output is correct
45 Correct 16 ms 23884 KB Output is correct
46 Correct 34 ms 29568 KB Output is correct
47 Correct 41 ms 29732 KB Output is correct
48 Correct 48 ms 30080 KB Output is correct
49 Correct 48 ms 30148 KB Output is correct
50 Correct 50 ms 30172 KB Output is correct
51 Correct 44 ms 30220 KB Output is correct
52 Correct 35 ms 26920 KB Output is correct
53 Correct 24 ms 25668 KB Output is correct
54 Correct 41 ms 29468 KB Output is correct
55 Correct 44 ms 30208 KB Output is correct
56 Correct 48 ms 29628 KB Output is correct
57 Correct 40 ms 29664 KB Output is correct
58 Correct 42 ms 29636 KB Output is correct
59 Correct 46 ms 29760 KB Output is correct
60 Correct 43 ms 29808 KB Output is correct
61 Correct 111 ms 53184 KB Output is correct
62 Correct 119 ms 53088 KB Output is correct
63 Correct 135 ms 53524 KB Output is correct
64 Correct 194 ms 55796 KB Output is correct
65 Correct 189 ms 56008 KB Output is correct
66 Correct 169 ms 56004 KB Output is correct
67 Correct 137 ms 49568 KB Output is correct
68 Correct 76 ms 36592 KB Output is correct
69 Correct 159 ms 52164 KB Output is correct
70 Correct 166 ms 55964 KB Output is correct
71 Correct 163 ms 53060 KB Output is correct
72 Correct 149 ms 53560 KB Output is correct
73 Correct 188 ms 54144 KB Output is correct
74 Correct 182 ms 54464 KB Output is correct
75 Correct 170 ms 54432 KB Output is correct