Submission #1147809

#TimeUsernameProblemLanguageResultExecution timeMemory
1147809Theo830Bali Sculptures (APIO15_sculpture)C++20
50 / 100
123 ms592 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training ll num = 0; ll dp[2005]; ll arr[2005]; ll n,a,b; ll po; ll solve(ll idx){ if(idx == n){ return 0; } if(dp[idx] != -1){ return dp[idx]; } ll ans = INF; ll sum = 0; f(k,idx,n){ sum += arr[k]; ll val = sum | num; val -= num; if(val < po){ ans = min(ans,1 + solve(k+1)); } } return dp[idx] = ans; } int main(void){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>a>>b; f(i,0,n){ cin>>arr[i]; } for(ll i = 60;i >= 0;i--){ po = (1LL<<i); memset(dp,-1,sizeof dp); if(solve(0) > b){ num += po; } } cout<<num<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...