Submission #317810

#TimeUsernameProblemLanguageResultExecution timeMemory
317810ali_tavakoliBali Sculptures (APIO15_sculpture)C++17
37 / 100
29 ms512 KiB
//In the name of Allah #include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' #define F first #define S second #define pb push_back #define al(x) x.begin(), x.end() const int N = 105, M = 31; int n, a, b, y[N]; bool dp[N][N]; int main() { cin >> n >> a >> b; for(int i = 0; i < n; i++) cin >> y[i]; ll ans = (1LL << M) - 1; for(int i = M - 1; i >= 0; i--) { for(int j = 0; j < N; j++) for(int k = 0; k < N; k++) dp[j][k] = 0; dp[0][0] = 1; for(int j = 0; j <= n; j++) for(int k = 0; k < N; k++) { ll sum = 0; for(int pos = j + 1; pos <= n; pos++) { sum += y[pos - 1]; if((sum | ans) > ans|| (1LL << i) & sum) continue; dp[pos][k + 1] |= dp[j][k]; } } for(int k = a; k <= b; k++) if(dp[n][k]) { ans -= (1LL << i); break; } } cout << ans << endl; }
#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...