# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1242123 | khanhdangiuu | Bali Sculptures (APIO15_sculpture) | C++20 | 1 ms | 328 KiB |
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define priority_queue priority_queue<array<long long,2>, vector<array<long long,2>>, greater<array<long long,2>>>
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define pi 3.14159265358979323846
#define pb push_back
#define fi first
#define se second
#define ar array
#define int long long
void chay()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "Hi"
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
const int N = 2e5, INF = 2e9+7;
const int block = 600;
const long long INFLL = 2e18+7;
long long M = 1e9+7;
int n, a, b, dung[N+5], c[N+5];
ll maxx;
bool ok[N+5];
bool check(ll maxx)
{
for (int i = 1; i <= n; i++) ok[i] = false;
for (int i = 1; i <= n; i++) dung[i] = INF;
ok[0] = 1;
for (int i = 1; i <= n; i++)
{
ll tong = 0;
for (int j = i; j >= 1; j--)
{
tong += c[j];
if (tong > maxx) break;
if (!((tong | maxx) == maxx)) continue;
if (ok[j-1])
{
dung[i] = min(dung[i], dung[j-1] + 1);
ok[i] = true;
}
}
}
return dung[n] <= b;
}
void solve()
{
cin>>n>>a>>b;
for (int i = 1; i <= n; i++) cin>>c[i];
maxx = (1ll<<36) - 1;
for (int i = 35; i >= 0; i--)
{
if (check(maxx - (1ll<<i)))
{
maxx -= (1ll<<i);
}
}
cout<<maxx;
}
signed main ()
{
//chay();
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin>>t;
while (t--)
{
solve();
}
return 0;
}
Compilation message (stderr)
# | 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... |