Submission #332457

# Submission time Handle Problem Language Result Execution time Memory
332457 2020-12-02T15:57:59 Z dolphingarlic Bigger segments (IZhO19_segments) C++14
100 / 100
94 ms 16108 KB
#include <stdio.h>
const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}

Compilation message

segments.cpp:2:55: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    2 | const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}
      |                                                       ^
segments.cpp: In function 'int main()':
segments.cpp:2:65: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=]
    2 | const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}
      |                                                                ~^  ~~
      |                                                                 |  |
      |                                                                 |  long int*
      |                                                                 int*
      |                                                                %ld
segments.cpp:2:98: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=]
    2 | const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}
      |                                                                                                 ~^  ~~~
      |                                                                                                  |   |
      |                                                                                                  |   long int*
      |                                                                                                  int*
      |                                                                                                 %ld
segments.cpp:2:249: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
    2 | const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}
      |                                                                                                                                                                                                                                                        ~^  ~~~~
      |                                                                                                                                                                                                                                                         |     |
      |                                                                                                                                                                                                                                                         int   long int
      |                                                                                                                                                                                                                                                        %ld
segments.cpp:2:62: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    2 | const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}
      |                                                         ~~~~~^~~~~~~~~
segments.cpp:2:95: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    2 | const int N=6e5;long a[N],b[N],c[N],l,r,d[N],n,i;main(){scanf("%d",&n);for(i=1;i<=n;++i){scanf("%d",a+i);a[i]+=a[i-1];while(r-l&&a[i]-a[d[l+1]]>=b[d[l+1]])++l;c[i]=c[d[l]]+1;b[i]=a[i]-a[d[l]];while(b[d[r]]-b[i]>=a[i]-a[d[r]])--r;d[++r]=i;}printf("%d",c[n]);}
      |                                                                                          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 0 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 0 ms 364 KB Output is correct
28 Correct 0 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 0 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 0 ms 364 KB Output is correct
28 Correct 0 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Correct 1 ms 364 KB Output is correct
43 Correct 1 ms 364 KB Output is correct
44 Correct 1 ms 364 KB Output is correct
45 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 0 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 0 ms 364 KB Output is correct
28 Correct 0 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Correct 1 ms 364 KB Output is correct
43 Correct 1 ms 364 KB Output is correct
44 Correct 1 ms 364 KB Output is correct
45 Correct 1 ms 364 KB Output is correct
46 Correct 13 ms 3436 KB Output is correct
47 Correct 14 ms 3180 KB Output is correct
48 Correct 25 ms 2796 KB Output is correct
49 Correct 18 ms 3052 KB Output is correct
50 Correct 18 ms 3436 KB Output is correct
51 Correct 19 ms 3300 KB Output is correct
52 Correct 9 ms 1772 KB Output is correct
53 Correct 6 ms 1268 KB Output is correct
54 Correct 14 ms 3308 KB Output is correct
55 Correct 22 ms 3436 KB Output is correct
56 Correct 18 ms 3436 KB Output is correct
57 Correct 15 ms 3436 KB Output is correct
58 Correct 15 ms 3436 KB Output is correct
59 Correct 16 ms 3436 KB Output is correct
60 Correct 19 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 0 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 0 ms 364 KB Output is correct
28 Correct 0 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Correct 1 ms 364 KB Output is correct
43 Correct 1 ms 364 KB Output is correct
44 Correct 1 ms 364 KB Output is correct
45 Correct 1 ms 364 KB Output is correct
46 Correct 13 ms 3436 KB Output is correct
47 Correct 14 ms 3180 KB Output is correct
48 Correct 25 ms 2796 KB Output is correct
49 Correct 18 ms 3052 KB Output is correct
50 Correct 18 ms 3436 KB Output is correct
51 Correct 19 ms 3300 KB Output is correct
52 Correct 9 ms 1772 KB Output is correct
53 Correct 6 ms 1268 KB Output is correct
54 Correct 14 ms 3308 KB Output is correct
55 Correct 22 ms 3436 KB Output is correct
56 Correct 18 ms 3436 KB Output is correct
57 Correct 15 ms 3436 KB Output is correct
58 Correct 15 ms 3436 KB Output is correct
59 Correct 16 ms 3436 KB Output is correct
60 Correct 19 ms 3436 KB Output is correct
61 Correct 67 ms 15980 KB Output is correct
62 Correct 70 ms 15980 KB Output is correct
63 Correct 73 ms 14956 KB Output is correct
64 Correct 85 ms 12908 KB Output is correct
65 Correct 86 ms 15980 KB Output is correct
66 Correct 94 ms 15216 KB Output is correct
67 Correct 90 ms 12268 KB Output is correct
68 Correct 37 ms 6252 KB Output is correct
69 Correct 70 ms 14952 KB Output is correct
70 Correct 87 ms 15732 KB Output is correct
71 Correct 72 ms 15980 KB Output is correct
72 Correct 70 ms 15212 KB Output is correct
73 Correct 74 ms 15340 KB Output is correct
74 Correct 76 ms 16108 KB Output is correct
75 Correct 79 ms 15980 KB Output is correct