/** author : Knquin_ **/
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
using ui64 = unsigned long long;
#define MASK(x) ((i64)(1) << (x))
#define BIT(mask , x) (((mask) >> (x)) & (1))
#define sz(x) (x).size()
#define all(x) (x).begin() , (x).end()
#define FOR(i ,a , b) for (int i = (a); i <= (b); ++i)
#define FORD(i , a , b) for (int i = (b); i >= (a); --i)
#define REP(i , a , b) for (int i = (a); i < (b); ++i)
#define REPD(i , a , b) for (int i = (b) - 1 ; i >= (a); --i)
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template<class T>
bool maximize(T &a , T b) {if (a < b) return a = b , true; else return false;}
template<class T>
bool minimize(T &a , T b) {if (a > b) return a = b , true; else return false;}
template<class T>
T gcd(T x , T y) {while (y) swap(y , x %= y); return x;}
template<class T>
T lcm(T x , T y) {return (x * y) / gcd(x , y);}
template <class T>
void compress(vector<T> &a)
{
sort(a.begin() , a.end());
a.resize(unique(a.begin() , a.end()) - a.begin());
return;
}
template<class T>
void printArr(T& container , string separator = "" , string finish = "\n")
{
for (auto& item : container) cout << item << separator;
cout << finish;
}
const int maxn = 2e3;
i64 a[maxn + 2];
int n , A , B;
namespace subtask1
{
bool condition()
{
return n <= 100;
}
const int N = 100;
i64 dp[N + 2][N + 2] , pre[N + 2];
void cook()
{
FOR(i , 1 , n)
pre[i] = pre[i - 1] + a[i];
memset(dp , 0x3f , sizeof dp);
dp[0][0] =0;
FOR(used , 1 , n)
{
FOR(i , 1 , n)
FOR(j , 1 , i)
{
if (dp[j - 1][used - 1] != dp[0][1])
minimize(dp[i][used] , (dp[j - 1][used - 1] | (pre[i] - pre[j - 1])));
}
}
i64 answer = (i64)1e18 + 7;
FOR(used , A , B) minimize(answer , dp[n][used]);
cout << answer << '\n';
}
}
int32_t main()
{
iostream::sync_with_stdio(false); cin.tie(0);
const string name = "main";
if (fopen((name + ".inp").c_str() , "r"))
{
(void)!freopen((name + ".inp").c_str() , "r" , stdin);
(void)!freopen((name + ".out").c_str() , "w+", stdout);
}
cin >> n >> A >> B;
FOR(i , 1 , n) cin >> a[i];
if (subtask1::condition()) return subtask1::cook() , 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |