Submission #396651

#TimeUsernameProblemLanguageResultExecution timeMemory
396651leinad2Bali Sculptures (APIO15_sculpture)C++17
71 / 100
1091 ms3788 KiB
#include<bits/stdc++.h> using namespace std; long long A[2010], ans, chk; int n, i, j, k, l, a, b, dp[2010][2010]; main() { for(scanf("%d %d %d", &n, &a, &b);i++<n;)scanf("%lld", &A[i]),A[i]+=A[i-1]; for(k=39;k>=0;k--) { for(i=0;i++<n;)for(j=0;j++<n;)dp[i][j]=0;dp[0][0]=1; chk+=(1LL<<k); for(i=0;i++<n;)for(j=0;j++<n;)for(l=0;l<i;l++) { if((chk&(A[i]-A[l]))==0&&dp[l][j-1]) { dp[i][j]=1; break; } } bool flag=false; for(i=a;i<=b;i++)if(dp[n][i])flag=true; if(!flag)chk-=(1LL<<k),ans+=(1LL<<k); } printf("%lld", ans); }

Compilation message (stderr)

sculpture.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      |      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:10:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   10 |         for(i=0;i++<n;)for(j=0;j++<n;)dp[i][j]=0;dp[0][0]=1;
      |         ^~~
sculpture.cpp:10:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   10 |         for(i=0;i++<n;)for(j=0;j++<n;)dp[i][j]=0;dp[0][0]=1;
      |                                                  ^~
sculpture.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     for(scanf("%d %d %d", &n, &a, &b);i++<n;)scanf("%lld", &A[i]),A[i]+=A[i-1];
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:7:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     for(scanf("%d %d %d", &n, &a, &b);i++<n;)scanf("%lld", &A[i]),A[i]+=A[i-1];
      |                                              ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...