이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100 + 5;
const long long INF = numeric_limits<long long>::max() / 2;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;
int dp[N][N], sum[N][N], A[N];
void solve()
{
int n, a, b; cin >> n >> a >> b;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
dp[i][j] = INF;
}
}
for(int i = 1; i <= n; ++i) cin >> A[i];
for(int i = 1; i <= n; ++i){
for(int j = i; j <= n; ++j){
sum[i][j] = sum[i][j - 1] + A[j];
}
dp[1][i] = sum[1][i];
}
int ans = INF;
if (a == 1) ans = dp[1][n];
for(int tme = 2; tme <= n; ++tme){
for(int i = tme; i <= n; ++i){
for(int j = tme; j <= i; ++j){
dp[tme][i] = min(dp[tme][i], dp[tme - 1][j - 1] | sum[j][i]);
}
}
if (tme >= a) ans = min(ans, dp[tme][n]);
}
cout << ans;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("codeforces.inp","r",stdin);
// freopen("codeforces.out","w",stdout);
int t = 1; //cin >> t;
while (t--)
{
solve();
}
}
# | 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... |