Submission #1134837

#TimeUsernameProblemLanguageResultExecution timeMemory
1134837Roumak77Bali Sculptures (APIO15_sculpture)C++20
25 / 100
1096 ms436 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <vector> #include <limits> #include <cmath> #include <stack> #include <queue> #include <map> #include <math.h> using namespace std; using ll = long long; ll n, a, b; ll curr_MIN = 1E18; void recur(ll idx, vector<ll> &list_n, vector<ll> &pref, ll val, ll curr){ if(curr > b){ return; } if(val >= curr_MIN){ return; } for(ll i = idx; i < n - 1; i++){ ll new_val = pref[i + 1] - pref[idx]; recur(i + 1, list_n, pref, val | new_val, curr + 1); } if(curr >= a){ ll new_val = pref[n] - pref[idx]; curr_MIN = min(curr_MIN, new_val | val); } } /* * * Score : 9/100 * */ void solve(){ cin >> n >> a >> b; vector<ll> list_n(n, 0); vector<ll> prefix(n + 1, 0); //ll dp[n][100]; for(ll i = 0; i < n; i++){ cin >> list_n[i]; prefix[i + 1] = prefix[i] + list_n[i]; } recur(0, list_n, prefix, 0, 1); cout << curr_MIN; } bool single = true; signed main(){ ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); ll t = 1; if(!single) cin >> t; while(t--){ solve(); } }
#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...