제출 #1128414

#제출 시각아이디문제언어결과실행 시간메모리
1128414NurislamBali Sculptures (APIO15_sculpture)C++17
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> inline bool chmin(T& a, const U& b) { if (a > b) { a = b; return true; } return false; } template<class T, class U> inline bool chmax(T& a, const U& b) { if (a < b) { a = b; return true; } return false; } #define pb push_back #define int long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define rep(i, s, f) for(int i = s; i < f; i++) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) const int inf = 3e18; void solve(){ int n, a, b; cin >> n >> a >> b; vector<int> v(n), pr{0}; for(int &i:v){ cin >> i; pr.pb(pr.back() + i); } vector<vector<int>> dp(n+1, vector<int> (b+1, inf)); dp[0][0] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j < i; j++){ for(int k = 0; k < b; k++){ chmin(dp[i][k+1], dp[j][k] | (pr[i] - pr[j])); } } } int ans = dp[n][b]; for(int i = a; i <= b; i++) chmin(ans, dp[n][i]); cout << ans << '\n'; }; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int tt = 1; //cin >> tt; while(tt--){ solve(); }; }
#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...