답안 #199420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199420 2020-02-01T10:45:34 Z semiauto Bigger segments (IZhO19_segments) C++14
73 / 100
1500 ms 14456 KB
#include <bits/stdc++.h>
using namespace std;
long long sum[500001],tree[1050000];
int dp[500001];
long long minn(long long a,long long b) {
    if (a>b)
        return b;
    return a;
}
void update(int pos,long long val) {
    while (pos) {
        tree[pos]=minn(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 minn(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;
        scanf("%d",&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;
}

Compilation message

segments.cpp: In function 'int main()':
segments.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 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 8572 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 9 ms 8568 KB Output is correct
8 Correct 9 ms 8568 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 9 ms 8568 KB Output is correct
11 Correct 10 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 11 ms 8568 KB Output is correct
14 Correct 9 ms 8568 KB Output is correct
15 Correct 9 ms 8572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 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 8572 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 9 ms 8568 KB Output is correct
8 Correct 9 ms 8568 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 9 ms 8568 KB Output is correct
11 Correct 10 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 11 ms 8568 KB Output is correct
14 Correct 9 ms 8568 KB Output is correct
15 Correct 9 ms 8572 KB Output is correct
16 Correct 9 ms 8568 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 10 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 8572 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 8572 KB Output is correct
28 Correct 11 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 9 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 8572 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 9 ms 8568 KB Output is correct
8 Correct 9 ms 8568 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 9 ms 8568 KB Output is correct
11 Correct 10 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 11 ms 8568 KB Output is correct
14 Correct 9 ms 8568 KB Output is correct
15 Correct 9 ms 8572 KB Output is correct
16 Correct 9 ms 8568 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 10 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 8572 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 8572 KB Output is correct
28 Correct 11 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 12 ms 8568 KB Output is correct
32 Correct 15 ms 8568 KB Output is correct
33 Correct 15 ms 8568 KB Output is correct
34 Correct 15 ms 8568 KB Output is correct
35 Correct 19 ms 8696 KB Output is correct
36 Correct 15 ms 8568 KB Output is correct
37 Correct 14 ms 8568 KB Output is correct
38 Correct 13 ms 8544 KB Output is correct
39 Correct 15 ms 8568 KB Output is correct
40 Correct 16 ms 8568 KB Output is correct
41 Correct 15 ms 8568 KB Output is correct
42 Correct 15 ms 8568 KB Output is correct
43 Correct 15 ms 8568 KB Output is correct
44 Correct 15 ms 8568 KB Output is correct
45 Correct 14 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 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 8572 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 9 ms 8568 KB Output is correct
8 Correct 9 ms 8568 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 9 ms 8568 KB Output is correct
11 Correct 10 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 11 ms 8568 KB Output is correct
14 Correct 9 ms 8568 KB Output is correct
15 Correct 9 ms 8572 KB Output is correct
16 Correct 9 ms 8568 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 10 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 8572 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 8572 KB Output is correct
28 Correct 11 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 12 ms 8568 KB Output is correct
32 Correct 15 ms 8568 KB Output is correct
33 Correct 15 ms 8568 KB Output is correct
34 Correct 15 ms 8568 KB Output is correct
35 Correct 19 ms 8696 KB Output is correct
36 Correct 15 ms 8568 KB Output is correct
37 Correct 14 ms 8568 KB Output is correct
38 Correct 13 ms 8544 KB Output is correct
39 Correct 15 ms 8568 KB Output is correct
40 Correct 16 ms 8568 KB Output is correct
41 Correct 15 ms 8568 KB Output is correct
42 Correct 15 ms 8568 KB Output is correct
43 Correct 15 ms 8568 KB Output is correct
44 Correct 15 ms 8568 KB Output is correct
45 Correct 14 ms 8568 KB Output is correct
46 Correct 196 ms 9720 KB Output is correct
47 Correct 375 ms 9848 KB Output is correct
48 Correct 373 ms 9720 KB Output is correct
49 Correct 371 ms 9848 KB Output is correct
50 Correct 345 ms 9720 KB Output is correct
51 Correct 373 ms 9848 KB Output is correct
52 Correct 176 ms 9080 KB Output is correct
53 Correct 102 ms 8824 KB Output is correct
54 Correct 374 ms 9944 KB Output is correct
55 Correct 377 ms 9720 KB Output is correct
56 Correct 361 ms 9756 KB Output is correct
57 Correct 370 ms 9720 KB Output is correct
58 Correct 364 ms 9848 KB Output is correct
59 Correct 338 ms 9720 KB Output is correct
60 Correct 368 ms 9720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 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 8572 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 9 ms 8568 KB Output is correct
7 Correct 9 ms 8568 KB Output is correct
8 Correct 9 ms 8568 KB Output is correct
9 Correct 9 ms 8568 KB Output is correct
10 Correct 9 ms 8568 KB Output is correct
11 Correct 10 ms 8568 KB Output is correct
12 Correct 9 ms 8568 KB Output is correct
13 Correct 11 ms 8568 KB Output is correct
14 Correct 9 ms 8568 KB Output is correct
15 Correct 9 ms 8572 KB Output is correct
16 Correct 9 ms 8568 KB Output is correct
17 Correct 10 ms 8568 KB Output is correct
18 Correct 10 ms 8568 KB Output is correct
19 Correct 10 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 8572 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 8572 KB Output is correct
28 Correct 11 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 12 ms 8568 KB Output is correct
32 Correct 15 ms 8568 KB Output is correct
33 Correct 15 ms 8568 KB Output is correct
34 Correct 15 ms 8568 KB Output is correct
35 Correct 19 ms 8696 KB Output is correct
36 Correct 15 ms 8568 KB Output is correct
37 Correct 14 ms 8568 KB Output is correct
38 Correct 13 ms 8544 KB Output is correct
39 Correct 15 ms 8568 KB Output is correct
40 Correct 16 ms 8568 KB Output is correct
41 Correct 15 ms 8568 KB Output is correct
42 Correct 15 ms 8568 KB Output is correct
43 Correct 15 ms 8568 KB Output is correct
44 Correct 15 ms 8568 KB Output is correct
45 Correct 14 ms 8568 KB Output is correct
46 Correct 196 ms 9720 KB Output is correct
47 Correct 375 ms 9848 KB Output is correct
48 Correct 373 ms 9720 KB Output is correct
49 Correct 371 ms 9848 KB Output is correct
50 Correct 345 ms 9720 KB Output is correct
51 Correct 373 ms 9848 KB Output is correct
52 Correct 176 ms 9080 KB Output is correct
53 Correct 102 ms 8824 KB Output is correct
54 Correct 374 ms 9944 KB Output is correct
55 Correct 377 ms 9720 KB Output is correct
56 Correct 361 ms 9756 KB Output is correct
57 Correct 370 ms 9720 KB Output is correct
58 Correct 364 ms 9848 KB Output is correct
59 Correct 338 ms 9720 KB Output is correct
60 Correct 368 ms 9720 KB Output is correct
61 Correct 1192 ms 14456 KB Output is correct
62 Execution timed out 1589 ms 14200 KB Time limit exceeded
63 Halted 0 ms 0 KB -