답안 #777024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777024 2023-07-08T13:57:39 Z khoquennguoiminhthuong Bigger segments (IZhO19_segments) C++14
100 / 100
71 ms 20804 KB
#include <bits/stdc++.h>
 
using namespace std;
int a[500005];
int n;
long long tong[500005];
long long dp[500005];
long long tree[500005];
void upd(int id,long long val)
{
while(id>0)
{
tree[id]=min(tree[id],val);id-=(id&(-id));
}
}
int pre[500005];
long long getmin(int id)
{
long long minn=1e18;
while(id<=n+1)
{
minn=min(minn,tree[id]);
id+=(id&(-id));
}
return minn;
}
int ans=0;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){cin>>a[i];tong[i]=tong[i-1]+a[i];}
dp[0]=0;
dp[1]=a[1];
int dd=0;
for(int i=1;i<=n+1;i++)tree[i]=1e18;
upd(1,0);
upd(2,2*a[1]);
for(int i=2;i<=n;i++)
{
while(dd<i-1&&tong[i]>=getmin(dd+2))dd++;
dp[i]=tong[i]-tong[dd];
pre[i]=dd;
upd(i+1,dp[i]+tong[i]);
}
int v=n;
while(v>0)
{
v=pre[v];
ans++;
}
cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 472 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 472 KB Output is correct
35 Correct 1 ms 396 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 472 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 472 KB Output is correct
35 Correct 1 ms 396 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 10 ms 3796 KB Output is correct
47 Correct 11 ms 3924 KB Output is correct
48 Correct 12 ms 4324 KB Output is correct
49 Correct 12 ms 4352 KB Output is correct
50 Correct 11 ms 4484 KB Output is correct
51 Correct 14 ms 4360 KB Output is correct
52 Correct 7 ms 2388 KB Output is correct
53 Correct 5 ms 1484 KB Output is correct
54 Correct 11 ms 3652 KB Output is correct
55 Correct 13 ms 4436 KB Output is correct
56 Correct 9 ms 3924 KB Output is correct
57 Correct 9 ms 3796 KB Output is correct
58 Correct 9 ms 3924 KB Output is correct
59 Correct 9 ms 4052 KB Output is correct
60 Correct 10 ms 4052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 472 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 472 KB Output is correct
35 Correct 1 ms 396 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 10 ms 3796 KB Output is correct
47 Correct 11 ms 3924 KB Output is correct
48 Correct 12 ms 4324 KB Output is correct
49 Correct 12 ms 4352 KB Output is correct
50 Correct 11 ms 4484 KB Output is correct
51 Correct 14 ms 4360 KB Output is correct
52 Correct 7 ms 2388 KB Output is correct
53 Correct 5 ms 1484 KB Output is correct
54 Correct 11 ms 3652 KB Output is correct
55 Correct 13 ms 4436 KB Output is correct
56 Correct 9 ms 3924 KB Output is correct
57 Correct 9 ms 3796 KB Output is correct
58 Correct 9 ms 3924 KB Output is correct
59 Correct 9 ms 4052 KB Output is correct
60 Correct 10 ms 4052 KB Output is correct
61 Correct 49 ms 17824 KB Output is correct
62 Correct 49 ms 17888 KB Output is correct
63 Correct 53 ms 18248 KB Output is correct
64 Correct 63 ms 20504 KB Output is correct
65 Correct 60 ms 20804 KB Output is correct
66 Correct 71 ms 20700 KB Output is correct
67 Correct 58 ms 16664 KB Output is correct
68 Correct 34 ms 8536 KB Output is correct
69 Correct 52 ms 17004 KB Output is correct
70 Correct 69 ms 20756 KB Output is correct
71 Correct 42 ms 17888 KB Output is correct
72 Correct 47 ms 18292 KB Output is correct
73 Correct 60 ms 18880 KB Output is correct
74 Correct 49 ms 19200 KB Output is correct
75 Correct 50 ms 19152 KB Output is correct