| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1343397 | minhtien | Bali Sculptures (APIO15_sculpture) | C++20 | 1 ms | 404 KiB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e3+5;
const ll inf=1e18+7;
int n;
int x,y;
ll a[N];
ll dp[N][N];
ll dp1[N];
ll tong2=inf;
ll tong=0;
int f(ll mask){
if(x==1){
for(int i=1;i<=n;i++){
dp1[i]=inf;
}
for(int i=1;i<=n;i++){
ll sum=0;
for(int j=i;j>=1;j--){
sum+=a[j];
if((sum|mask)==mask){
dp1[i]=min(dp1[i],dp1[j-1]+1);
}
}
}
if(dp1[n]<=y) return 1;
return 0;
}
else{
dp[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=n;j++){
dp[i][j]=0;
}
}
for(int i=1;i<=n;i++){
ll sum=0;
for(int j=i;j>=1;j--){
sum+=a[j];
if((sum|mask)==mask){
for(int k=1;k<=y;k++){
if(dp[j-1][k-1]){
dp[i][k]=1;
}
}
}
}
}
for(int j=x;j<=y;j++){
if(dp[n][j]) return 1;
}
return 0;
}
}
int main()
{
cin >>n >>x >>y;
for(int i=1;i<=n;i++){
cin >> a[i];
}
for(int j=41;j>=0;j--){
ll tong1=(tong|((1<<j)-1));
if(f(tong1)==0){
tong|=(1<<j);
}
}
cout << tong;
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... | ||||
