Submission #869202

#TimeUsernameProblemLanguageResultExecution timeMemory
869202sleepntsheepBigger segments (IZhO19_segments)C++17
Compilation error
0 ms0 KiB
#include <stdio.h> #define N 500001 i,j,n,dp[N]; long long a[N], fw[N],x,c,p; u(int p, long long k) { for (;p<N;p+=p&-p) fw[p]-=(fw[p]-k)*(k<fw[p]); } //long long q(p) { long long z=1e18;for(;p;p-=p&-p)z-=(z-fw[p])*(z>fw[p]); return z;} s(){ c=0,p=1e18; for(int j=(1<<19);j;j>>=1)if(c+j<=n&&(fw[j+c]<p?fw[j+c]:p)>x)c+=j,p=(fw[c]<p?fw[c]:p); return c+1; } main() { scanf("%d",&n);for(;++i<N;fw[i]=1e18); for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],u(n-i+1,2*a[i]-a[j]); printf("%d",dp[n]); return 0; }

Compilation message (stderr)

segments.cpp:4:1: error: 'i' does not name a type
    4 | i,j,n,dp[N];
      | ^
segments.cpp:6:1: error: ISO C++ forbids declaration of 'u' with no type [-fpermissive]
    6 | u(int p, long long k) { for (;p<N;p+=p&-p) fw[p]-=(fw[p]-k)*(k<fw[p]); }
      | ^
segments.cpp: In function 'int u(int, long long int)':
segments.cpp:6:72: warning: no return statement in function returning non-void [-Wreturn-type]
    6 | u(int p, long long k) { for (;p<N;p+=p&-p) fw[p]-=(fw[p]-k)*(k<fw[p]); }
      |                                                                        ^
segments.cpp: At global scope:
segments.cpp:8:1: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
    8 | s(){
      | ^
segments.cpp: In function 'int s()':
segments.cpp:10:39: error: 'n' was not declared in this scope
   10 |     for(int j=(1<<19);j;j>>=1)if(c+j<=n&&(fw[j+c]<p?fw[j+c]:p)>x)c+=j,p=(fw[c]<p?fw[c]:p);
      |                                       ^
segments.cpp: At global scope:
segments.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~
segments.cpp: In function 'int main()':
segments.cpp:15:17: error: 'n' was not declared in this scope
   15 |     scanf("%d",&n);for(;++i<N;fw[i]=1e18);
      |                 ^
segments.cpp:15:27: error: 'i' was not declared in this scope
   15 |     scanf("%d",&n);for(;++i<N;fw[i]=1e18);
      |                           ^
segments.cpp:16:10: error: 'i' was not declared in this scope
   16 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],u(n-i+1,2*a[i]-a[j]);
      |          ^
segments.cpp:16:57: error: 'dp' was not declared in this scope; did you mean 'p'?
   16 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],u(n-i+1,2*a[i]-a[j]);
      |                                                         ^~
      |                                                         p
segments.cpp:16:68: error: 'j' was not declared in this scope
   16 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],u(n-i+1,2*a[i]-a[j]);
      |                                                                    ^
segments.cpp:17:17: error: 'dp' was not declared in this scope; did you mean 'p'?
   17 |     printf("%d",dp[n]);
      |                 ^~
      |                 p