Submission #171688

#TimeUsernameProblemLanguageResultExecution timeMemory
171688Nodir_BobievBali Sculptures (APIO15_sculpture)C++14
71 / 100
1082 ms4472 KiB
# include <bits/stdc++.h> # define FILE using namespace std; int n, a, b; long long y[2010], ans; bool check( long long mask ){ bool dp[2010][2010] = {}; dp[0][0] = 1; for( int i = 1; i <= n; i ++ ){ for( int j = 1; j <= i; j ++ ){ if( (mask|(y[i]-y[j-1])) == mask ){ for( int k = 0; k < 2000; k ++ ){ if( dp[j-1][k] ) dp[i][k+1] = 1; } } } } for( int i = a; i <= b; i ++ ){ if( dp[n][i] )return true; } return false; } int main(){ # ifdef FILEs freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout ); # endif ios_base::sync_with_stdio(false); cin >> n >> a >> b; for( int i = 1; i <= n; i ++ ){ cin >> y[i]; y[i] += y[i-1]; } ans = (1ll << 50)-1; for( int i = 49; i >= 0; i -- ){ ans -= (1ll << i); if( check( ans ) == false )ans += (1ll << i); } cout << ans; }
#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...