#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a,b;
int y[201];
int sum[201][201];
int dp[201][201];
int get(int num,int r){
if(r==1)return sum[1][num];
if(num==1)return y[1];
int res=sum[1][num];
if(dp[num][r]>=0)return dp[num][r];
for(int i=1;i<num;i++)
res=min(res,get(i,r-1)|sum[i+1][num]);
return dp[num][r]=res;
}
int main()
{ cin.tie(0);
ios_base::sync_with_stdio(false);
memset(dp,-1,sizeof(dp));
cin >> n >> a >> b;
for(int i=1;i<=n;i++)
cin >> y[i];
for(int i=1;i<=n;i++){
int r=0;
for(int j=i;j<=n;j++){
r+=y[j];
sum[i][j]=r;
}
}
cout << get(n,b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |