이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define see(x) cout<<#x<<"="<<x<<endl;
#define endl "\n"
using namespace std;
const int INF = 1e18;
int n, a, b, y[105];
int dp[105][105], pref[105];
int ans = INF;
void brute(int i, int res, int rem) {
if (rem < 0) return;
if (i == n) {
if (!rem) ans = min(ans, res);
return;
}
int sum = 0;
for (int j = i + 1; j <= n; j ++) {
sum += y[j];
brute(j, (res | sum), rem - 1);
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
cin >> n >> a >> b;
for (int i = 1; i <= n; i ++) {
cin >> y[i];
pref[i] = pref[i-1] + y[i];
}
for (int i = a; i <= b; i ++) {
brute(0, 0, i);
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |