Submission #106938

#TimeUsernameProblemLanguageResultExecution timeMemory
106938nxteruBali Sculptures (APIO15_sculpture)C++14
100 / 100
84 ms512 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double D; typedef pair<ll,ll> P; #define M 1000000007 #define F first #define S second #define PB push_back #define INF 1000000000000000000 int n,a,b; ll y[2005],ans=(1LL<<41LL)-1; bool check(void){ if(a==1){ int dp[2005]; for(int i=0;i<=n;i++)dp[i]=n+1; dp[0]=0; for(int i=0;i<n;i++){ ll s=0; for(int j=i+1;j<=n;j++){ s+=y[j]; if((ans|s)==ans)dp[j]=min(dp[j],dp[i]+1); } } return dp[n]<=b; }else{ bool dp[105][105]; for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=false; dp[0][0]=true; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(!dp[i][j])continue; ll s=0; for(int k=i+1;k<=n;k++){ s+=y[k]; if((ans|s)==ans)dp[k][j+1]=true; } } } bool res=false; for(int i=a;i<=b;i++)res|=dp[n][i]; return res; } } int main(void){ scanf("%d%d%d",&n,&a,&b); for(int i=1;i<=n;i++)scanf("%lld",y+i); for(ll i=40;i>=0;i--){ ans^=(1LL<<i); if(!check())ans^=(1LL<<i); } printf("%lld\n",ans); }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:47:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++)scanf("%lld",y+i);
                       ~~~~~^~~~~~~~~~~~
#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...