#include <iostream>
using namespace std;
const int NMAX = 2e3 + 5;
int N, A, B, Y[NMAX];
long long sp[NMAX], BitMask;
static inline void Read ()
{
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> A >> B;
for(int i = 1; i <= N; ++i)
cin >> Y[i], sp[i] = sp[i - 1] + 1LL * Y[i];
return;
}
auto Check = [] (int byte, long long Sum)
{
if(Sum & (1LL << byte))
return 0;
Sum >>= (byte + 1);
if((Sum ^ BitMask) == 0LL)
return 1;
return 0;
};
static inline bool Ok (int byte)
{
bool dp[N + 1][N + 1];
for(int i = 0; i <= N; ++i)
for(int j = 0; j <= N; ++j)
dp[i][j] = 0;
dp[0][0] = 1;
for(int i = 1; i <= N; ++i)
for(int j = 1; j <= i; ++j)
for(int k = 0; k < i && !dp[i][j]; ++k)
if(dp[k][j - 1] && Check(byte, sp[i] - sp[k]))
dp[i][j] = 1;
for(int i = A; i <= B; ++i)
if(dp[N][i])
return 1;
return 0;
}
static inline void Solve_1 ()
{
long long ans = 0;
for(int i = 40; i >= 0; --i)
{
bool Now = Ok(i);
BitMask = (BitMask << 1LL);
if(Now)
continue;
else
ans += 1LL * (1LL << i), ++BitMask;
}
cout << ans << '\n';
return;
}
static inline void Solve ()
{
if(N <= 1e2)
Solve_1();
return;
}
int main()
{
Read();
Solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |