제출 #1191226

#제출 시각아이디문제언어결과실행 시간메모리
1191226TsaganaBali Sculptures (APIO15_sculpture)C++20
100 / 100
62 ms484 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; void solve () { int n, s, e; cin >> n >> s >> e; int a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; int ans = (1LL << 41) - 1; int l[n + 1], r[n + 1]; l[0] = r[0] = 0; for (int k = 40; k >= 0; k--) { ans ^= 1LL << k; for (int i = 1; i <= n; i++) { l[i] = INT_MAX, r[i] = INT_MIN; int s = 0; for (int j = i-1; j >= 0; j--) { s += a[j + 1]; if ((s & ans) == s) { l[i] = min(l[i], l[j] + 1); r[i] = max(r[i], r[j] + 1); } } } if (!(s <= r[n] && l[n] <= e)) ans ^= 1LL << k; } cout << ans << '\n'; } signed main() {IOS solve(); 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...