Submission #489706

#TimeUsernameProblemLanguageResultExecution timeMemory
489706mdn2002Bali Sculptures (APIO15_sculpture)C++14
71 / 100
1060 ms31904 KiB
#include<bits/stdc++.h> using namespace std; long long n , a , b , y [2003] , dp [2003][2003] , mask; long long f ( int x , int num ) { if ( x == n ) { if ( a <= num && num <= b ) return 1; return 0; } if ( dp [x][num] != -1 ) return dp [x][num]; long long ans = 0 , sum = 0; for ( int i = x ; i < n ; i ++ ) { sum += y [i]; if ( ( mask | sum ) > mask ) continue; ans = max ( ans , f ( i + 1 , num + 1 ) ); } return dp [x][num] = ans; } bool ck ( ) { memset ( dp , -1 , sizeof dp ); return f ( 0 , 0 ); } int main() { //freopen ( "fence8.in" , "r" , stdin ); //freopen ( "fence8.out" , "w" , stdout ); cin >> n >> a >> b; for ( int i = 0 ; i < n ; i ++ ) cin >> y [i]; mask = ( 1ll << 50 ) - 1; for ( int i = 49 ; i >= 0 ; i -- ) { mask ^= ( 1ll << i ); if ( ck ( ) == 0 ) mask ^= ( 1ll << i ); } cout << mask; }
#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...