이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
using namespace std;
const int inf = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int32_t main(){
ios_base::sync_with_stdio(false), cin.tie();
int n, a, b;
cin>>n>>a>>b;
int dp[n+1][n+1];
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
dp[i][j] = inf;
}
}
dp[0][0] = 0;
vector<int> arr(n+1), pre(n+1);
for(int i = 1; i <= n; i++){
cin>>arr[i];
pre[i] = pre[i-1] + arr[i];
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
for(int k = j + 1; k <= n; k++){
dp[k][j+1] = min(dp[k][j+1], dp[i][j]|(pre[k] - pre[i]));
}
}
}
int ans = inf;
for(int i = a; i <= b; i++){
ans = min(ans, dp[n][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... |