#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, A, B;
ll x[2000];
bool start[2000] = {false};
int cnt = 0;
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin >> n >> A >> B;
for (int i = 0; i < n; i++)
cin >> x[i];
ll ans = 0;
for (ll y = 1LL << 41; y >= 1; y /= 2)
{
ll sum = y;
vector<int> new_splits;
for (int i = 0; i < n; i++)
{
if (start[i])
sum = 0;
else if (sum + x[i] >= ans + y)
{
sum = 0, start[i] = true;
new_splits.push_back(i);
cnt++;
}
sum += x[i];
}
if (cnt > B)
{
ans += y, cnt -= new_splits.size();
for (int i : new_splits)
start[i] = false;
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |