Submission #388794

#TimeUsernameProblemLanguageResultExecution timeMemory
388794talant117408Bali Sculptures (APIO15_sculpture)C++17
0 / 100
1 ms572 KiB
/* Code written by Talant I.D. */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) int((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; const int mod = 1e9+7; ll mode(ll a) { a %= mod; if (a < 0) a += mod; return a; } ll subt(ll a, ll b) { return mode(mode(a)-mode(b)); } ll add(ll a, ll b) { return mode(mode(a)+mode(b)); } ll mult(ll a, ll b) { return mode(mode(a)*mode(b)); } ll binpow(ll a, ll b) { ll res = 1; while (b) { if (b&1) res = mult(res, a); a = mult(a, a); b >>= 1; } return res; } const int N = 103; vector <ll> dp[N][N]; int main() { do_not_disturb int n, a, b; cin >> n >> a >> b; vector <ll> v(n+1), pref(n+1); for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= n; i++) pref[i] = pref[i-1]+v[i]; for (int i = 1; i <= n; i++) { dp[1][i].pb(pref[i]); } for (int k = 2; k <= b; k++) { for (int i = k; i <= n; i++) { for (int j = i-1; j >= k-1; j--) { ll mn = 1e18; for (auto to : dp[k-1][j]) { mn = min(mn, (to|(pref[i]-pref[j]))); } dp[k][i].pb(mn); } } } ll ans = 1e18; for (int k = a; k <= b; k++) { ans = min(ans, *min_element(all(dp[k][n]))); } cout << ans; return 0; }
#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...