제출 #170823

#제출 시각아이디문제언어결과실행 시간메모리
170823NightmarBali Sculptures (APIO15_sculpture)C++17
46 / 100
770 ms262148 KiB
#include <iostream> #include <algorithm> #include <cmath> #include <string> #include <cstdlib> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <iomanip> #define SWS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pb push_back #define ppb pop_back #define ft first #define sd second #define read freopen("input.txt", "r", stdin) #define write freopen("output.txt", "w", stdout) #define files read; write using namespace std; typedef long long ll; typedef pair<int, int> pii; const int Z = (int)2e3 + 228; const int N = (int)3e5 + 228; const int INF = (int)1e9 + 228; const int MOD = (int)1e9 + 7; const ll LLINF = (ll)1e15 + 228; ll a[Z], pref[Z]; set<ll> dp[Z][Z]; int main() { SWS; //files; int n, l, r; cin >> n >> l >> r; for (int i = 1; i <= n; i++) { cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } dp[0][0].insert(0); for (int team = 1; team < l; team++) for (int i = team; i <= n; i++) for (int j = team - 1; j < i; j++) for (auto it : dp[team - 1][j]) { ll x = it | (pref[i] - pref[j]); dp[team][i].insert(x); } ll ans = LLINF; for (int team = l; team <= r; team++) { for (int i = team; i <= n; i++) for (int j = team - 1; j < i; j++) for (auto it : dp[team - 1][j]) { ll x = it | (pref[i] - pref[j]); dp[team][i].insert(x); if (i == n) ans = min(ans, x); } } cout << ans; return 0; } /* 6 1 3 8 1 2 1 5 4 */
#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...