제출 #853676

#제출 시각아이디문제언어결과실행 시간메모리
853676NeroZeinBali Sculptures (APIO15_sculpture)C++17
50 / 100
160 ms600 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, u, b; cin >> n >> u >> b; vector<int> a(n + 1); vector<long long> pref(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } long long d = 0; long long ans = 0; for (int bit = 60; bit >= 0; --bit) { d |= 1LL << bit; vector<int> dp(n + 1, b + 1); dp[0] = 0; for (int i = 1; i <= n; ++i) { for (int j = i - 1; j >= 0; --j) { long long sum = pref[i] - pref[j]; if ((sum & d) == 0) { dp[i] = min(dp[i], dp[j] + 1); } } } if (dp[n] > b) { d ^= 1LL << bit; ans |= 1LL << bit; } } cout << ans << '\n'; 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...