Submission #882908

#TimeUsernameProblemLanguageResultExecution timeMemory
882908Onur_IlgazBali Sculptures (APIO15_sculpture)C++17
21 / 100
1 ms604 KiB
#include <bits/stdc++.h> #define fast cin.tie(0)->sync_with_stdio(0); #define int long long #define inf ((int)1e18) using namespace std; vector <int> arr(101), pref(101); bool solve(int val, int n, int a, int b) { vector<int> dp(n + 1, inf); dp[0] = 0; for(int i = 1; i <= n; i++) { for(int from = 0; from < i; from++) { if(((pref[i] - pref[from]) & val) == 0) { dp[i] = min(dp[i], dp[from] + 1); // dp[i] = i'ye kadar min kaç bölmelendirmeyle value'ya ulaşılabilinir } } } return (dp[n] <= b); } int32_t main(){ fast int n, a, b; cin >> n >> a >> b; for(int i = 1; i <= n; i++) { cin >> arr[i]; pref[i] = pref[i-1] + arr[i]; } int val = 0; for(int bit = (1ll << 60ll); bit > 0; bit /= 2) { bool ans = solve(val + bit, n, a, b); val += ans * bit; } cout << (((1ll << 61ll) - 1) ^ val) << "\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...