답안 #199417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199417 2020-02-01T10:42:32 Z semiauto Bigger segments (IZhO19_segments) C++14
73 / 100
1500 ms 16504 KB
#include <bits/stdc++.h>
using namespace std;
long long sum[500001],tree[1050000];
int dp[500001];
void update(int pos,long long val) {
    while (pos) {
        tree[pos]=min(tree[pos],val);
        pos/=2;
    }
}
long long solve(int p,int l,int r,int x,int y) {
    if (x>r || l>y)
        return 2000000000000000000ll;
    if (l>=x && r<=y)
        return tree[p];
    return min(solve(2*p,l,(l+r)/2,x,y),solve(2*p+1,(l+r)/2+1,r,x,y));
}
int main() {
    for (int i=0;i<1050000;i++)
        tree[i]=2000000000000000000ll;
    int n,N=1;
    cin>>n;
    while (N<n)
        N*=2;
    for (int i=1;i<=n;i++) {
        int x;
        cin>>x;
        sum[i]=sum[i-1]+x;
        int pos=i;
        for (int j=18;j>=0;j--)
            if (pos-(1<<j)>0 && solve(1,N,2*N-1,pos-(1<<j)+N-1,pos-1+N-1)>sum[i])
                pos-=(1<<j);
        dp[i]=dp[pos-1]+1;
        update(i+N-1,2*sum[i]-sum[pos-1]);
    }
    cout<<dp[n]<<endl;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Correct 9 ms 8568 KB Output is correct
3 Correct 9 ms 8568 KB Output is correct
4 Correct 9 ms 8568 KB Output is correct
5 Correct 9 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 10 ms 8568 KB Output is correct
8 Correct 10 ms 8700 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 10 ms 8572 KB Output is correct
11 Correct 9 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 9 ms 8568 KB Output is correct
14 Correct 10 ms 8568 KB Output is correct
15 Correct 10 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Correct 9 ms 8568 KB Output is correct
3 Correct 9 ms 8568 KB Output is correct
4 Correct 9 ms 8568 KB Output is correct
5 Correct 9 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 10 ms 8568 KB Output is correct
8 Correct 10 ms 8700 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 10 ms 8572 KB Output is correct
11 Correct 9 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 9 ms 8568 KB Output is correct
14 Correct 10 ms 8568 KB Output is correct
15 Correct 10 ms 8568 KB Output is correct
16 Correct 11 ms 8544 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 11 ms 8568 KB Output is correct
20 Correct 11 ms 8568 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8568 KB Output is correct
23 Correct 10 ms 8568 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 10 ms 8568 KB Output is correct
26 Correct 10 ms 8568 KB Output is correct
27 Correct 10 ms 8568 KB Output is correct
28 Correct 10 ms 8568 KB Output is correct
29 Correct 10 ms 8568 KB Output is correct
30 Correct 10 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Correct 9 ms 8568 KB Output is correct
3 Correct 9 ms 8568 KB Output is correct
4 Correct 9 ms 8568 KB Output is correct
5 Correct 9 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 10 ms 8568 KB Output is correct
8 Correct 10 ms 8700 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 10 ms 8572 KB Output is correct
11 Correct 9 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 9 ms 8568 KB Output is correct
14 Correct 10 ms 8568 KB Output is correct
15 Correct 10 ms 8568 KB Output is correct
16 Correct 11 ms 8544 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 11 ms 8568 KB Output is correct
20 Correct 11 ms 8568 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8568 KB Output is correct
23 Correct 10 ms 8568 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 10 ms 8568 KB Output is correct
26 Correct 10 ms 8568 KB Output is correct
27 Correct 10 ms 8568 KB Output is correct
28 Correct 10 ms 8568 KB Output is correct
29 Correct 10 ms 8568 KB Output is correct
30 Correct 10 ms 8568 KB Output is correct
31 Correct 13 ms 8568 KB Output is correct
32 Correct 17 ms 8568 KB Output is correct
33 Correct 16 ms 8568 KB Output is correct
34 Correct 16 ms 8572 KB Output is correct
35 Correct 16 ms 8568 KB Output is correct
36 Correct 16 ms 8568 KB Output is correct
37 Correct 15 ms 8572 KB Output is correct
38 Correct 14 ms 8568 KB Output is correct
39 Correct 16 ms 8568 KB Output is correct
40 Correct 16 ms 8696 KB Output is correct
41 Correct 16 ms 8568 KB Output is correct
42 Correct 16 ms 8568 KB Output is correct
43 Correct 17 ms 8568 KB Output is correct
44 Correct 16 ms 8568 KB Output is correct
45 Correct 15 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Correct 9 ms 8568 KB Output is correct
3 Correct 9 ms 8568 KB Output is correct
4 Correct 9 ms 8568 KB Output is correct
5 Correct 9 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 10 ms 8568 KB Output is correct
8 Correct 10 ms 8700 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 10 ms 8572 KB Output is correct
11 Correct 9 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 9 ms 8568 KB Output is correct
14 Correct 10 ms 8568 KB Output is correct
15 Correct 10 ms 8568 KB Output is correct
16 Correct 11 ms 8544 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 11 ms 8568 KB Output is correct
20 Correct 11 ms 8568 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8568 KB Output is correct
23 Correct 10 ms 8568 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 10 ms 8568 KB Output is correct
26 Correct 10 ms 8568 KB Output is correct
27 Correct 10 ms 8568 KB Output is correct
28 Correct 10 ms 8568 KB Output is correct
29 Correct 10 ms 8568 KB Output is correct
30 Correct 10 ms 8568 KB Output is correct
31 Correct 13 ms 8568 KB Output is correct
32 Correct 17 ms 8568 KB Output is correct
33 Correct 16 ms 8568 KB Output is correct
34 Correct 16 ms 8572 KB Output is correct
35 Correct 16 ms 8568 KB Output is correct
36 Correct 16 ms 8568 KB Output is correct
37 Correct 15 ms 8572 KB Output is correct
38 Correct 14 ms 8568 KB Output is correct
39 Correct 16 ms 8568 KB Output is correct
40 Correct 16 ms 8696 KB Output is correct
41 Correct 16 ms 8568 KB Output is correct
42 Correct 16 ms 8568 KB Output is correct
43 Correct 17 ms 8568 KB Output is correct
44 Correct 16 ms 8568 KB Output is correct
45 Correct 15 ms 8568 KB Output is correct
46 Correct 219 ms 10104 KB Output is correct
47 Correct 397 ms 10360 KB Output is correct
48 Correct 405 ms 10748 KB Output is correct
49 Correct 390 ms 10616 KB Output is correct
50 Correct 407 ms 10852 KB Output is correct
51 Correct 411 ms 10744 KB Output is correct
52 Correct 194 ms 9592 KB Output is correct
53 Correct 106 ms 9208 KB Output is correct
54 Correct 380 ms 9976 KB Output is correct
55 Correct 406 ms 10748 KB Output is correct
56 Correct 378 ms 10232 KB Output is correct
57 Correct 373 ms 10208 KB Output is correct
58 Correct 366 ms 10348 KB Output is correct
59 Correct 373 ms 10456 KB Output is correct
60 Correct 384 ms 10364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Correct 9 ms 8568 KB Output is correct
3 Correct 9 ms 8568 KB Output is correct
4 Correct 9 ms 8568 KB Output is correct
5 Correct 9 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 10 ms 8568 KB Output is correct
8 Correct 10 ms 8700 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 10 ms 8572 KB Output is correct
11 Correct 9 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 9 ms 8568 KB Output is correct
14 Correct 10 ms 8568 KB Output is correct
15 Correct 10 ms 8568 KB Output is correct
16 Correct 11 ms 8544 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 11 ms 8568 KB Output is correct
20 Correct 11 ms 8568 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8568 KB Output is correct
23 Correct 10 ms 8568 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 10 ms 8568 KB Output is correct
26 Correct 10 ms 8568 KB Output is correct
27 Correct 10 ms 8568 KB Output is correct
28 Correct 10 ms 8568 KB Output is correct
29 Correct 10 ms 8568 KB Output is correct
30 Correct 10 ms 8568 KB Output is correct
31 Correct 13 ms 8568 KB Output is correct
32 Correct 17 ms 8568 KB Output is correct
33 Correct 16 ms 8568 KB Output is correct
34 Correct 16 ms 8572 KB Output is correct
35 Correct 16 ms 8568 KB Output is correct
36 Correct 16 ms 8568 KB Output is correct
37 Correct 15 ms 8572 KB Output is correct
38 Correct 14 ms 8568 KB Output is correct
39 Correct 16 ms 8568 KB Output is correct
40 Correct 16 ms 8696 KB Output is correct
41 Correct 16 ms 8568 KB Output is correct
42 Correct 16 ms 8568 KB Output is correct
43 Correct 17 ms 8568 KB Output is correct
44 Correct 16 ms 8568 KB Output is correct
45 Correct 15 ms 8568 KB Output is correct
46 Correct 219 ms 10104 KB Output is correct
47 Correct 397 ms 10360 KB Output is correct
48 Correct 405 ms 10748 KB Output is correct
49 Correct 390 ms 10616 KB Output is correct
50 Correct 407 ms 10852 KB Output is correct
51 Correct 411 ms 10744 KB Output is correct
52 Correct 194 ms 9592 KB Output is correct
53 Correct 106 ms 9208 KB Output is correct
54 Correct 380 ms 9976 KB Output is correct
55 Correct 406 ms 10748 KB Output is correct
56 Correct 378 ms 10232 KB Output is correct
57 Correct 373 ms 10208 KB Output is correct
58 Correct 366 ms 10348 KB Output is correct
59 Correct 373 ms 10456 KB Output is correct
60 Correct 384 ms 10364 KB Output is correct
61 Correct 1256 ms 16504 KB Output is correct
62 Execution timed out 1506 ms 15816 KB Time limit exceeded
63 Halted 0 ms 0 KB -