제출 #1350621

#제출 시각아이디문제언어결과실행 시간메모리
1350621bakhtiyarnBali Sculptures (APIO15_sculpture)C++20
9 / 100
389 ms327680 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 2000+5;
int a[N];

// for(int i=1; i<=n; i++) 
void solve(){
  int n, L, R; cin >> n >> L >> R;
  for(int i=1; i<=n; i++) cin >> a[i];
  
  vector<vector<long long>> dp(n+1);
  dp[0].push_back(0);
  long long mn = 1e18;
  for(int g=1; g<=R; g++){
    vector<vector<long long>> n_dp(n+1);
    for(int i=1; i<=n; i++) {
      long long sm = 0;
      for(int j=i; j>=1; j--){
        sm += a[j];
        for(long long OR: dp[j-1]){
          if((sm|OR) <= mn) n_dp[i].push_back(sm | OR);
        }
      }
      n_dp[i].erase(unique(n_dp[i].begin(), n_dp[i].end()), n_dp[i].end());
    }
    swap(dp, n_dp);
    
    if(g >= L) for(long long OR: dp[n]) mn = min(mn, OR);
  }
  
  
  cout << mn;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...