This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
long long n , a , b , y [2003] , dp [2003][2003];
long long f ( int x , int num )
{
if ( x == n && a <= num && num <= b ) return 0;
if ( x == n ) return 1e16;
//if ( dp [x][num] != -1 ) return dp [x][num];
long long ans = 1e16 , sum = 0;
for ( int i = x ; i < n ; i ++ )
{
sum += y [i];
ans = min ( ans , ( f ( i + 1 , num + 1 ) | sum ) );
}
return dp [x][num] = ans;
}
int main()
{
//freopen ( "fence8.in" , "r" , stdin );
//freopen ( "fence8.out" , "w" , stdout );
memset ( dp , -1 , sizeof dp );
cin >> n >> a >> b;
for ( int i = 0 ; i < n ; i ++ ) cin >> y [i];
cout << f ( 0 , 0 );
}
/*
4 1 4
2 3 1 4
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |