답안 #882422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882422 2023-12-03T07:23:00 Z vjudge1 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 4856 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;


ll n, a, b, A[N], pref[N];
set<ll> dp[105][105];
void solve(){
  cin >> n >> a >> b;
  for(int i = 1; i <= n; ++i) cin >> A[i];
  pref[0] = 0;
  for(int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + A[i];
  dp[0][0].insert(0);
  for(int i = 1; i <= n; ++i){
    for(int j = 0; j < i; ++j){
      for(int k = 1; k <= j + 1; ++k){
        for(auto s: dp[j][k - 1])
          dp[i][j].insert(s | (pref[i] - pref[j]));
      }
    }
  } 
  ll ans = 1e18;
  for(int i = a; i <= b; ++i){
    if(dp[n][i].empty()) continue;
    ans = min(ans, *prev(dp[n][i].end()));
  }
  cout << ans;
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // cin >> tt;
  while(tt--){
    solve();
    en;
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:40:15: warning: unused variable 'aa' [-Wunused-variable]
   40 |   int tt = 1, aa;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Incorrect 1 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Incorrect 1 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4856 KB Output is correct
2 Incorrect 1 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Incorrect 1 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Incorrect 1 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -