답안 #1085485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085485 2024-09-08T10:30:14 Z mingga Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 348 KB
#include "bits/stdc++.h"

using namespace std;

#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define inf 2e18
#define fast_cin()                  \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define out(file) freopen(file, "w", stdout)
#define in(file) freopen(file, "r", stdin)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
int MOD = 1e9 + 7;
const int N = 2001;
int y[N], a, b, n;
int ps[N], dp[N][N];

void sub1() {
  int ans = inf;
  for(int mask = 0; mask < (1 << n); mask++) {
    int cnt = __builtin_popcount(mask) + 1;
    if(cnt < a or cnt > b) continue;
    int grp = 0;
    int s = 0;
    int cur = 0;
    for(int i = 0; i < n; i++) {
      s += y[i+1];
      if((mask >> i) & 1) {
        grp++;
        cur |= s;
        s = 0;
      }
    }
    cur |= s;
    if((mask >> (n-1)) & 1 == 0) grp++;
    if(a < grp or grp > b) continue;
    ans = min(ans, cur);
  }
  cout << ans;
}

signed main() {
    fast_cin();
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++) cin >> y[i], ps[i] = ps[i-1] + y[i];
    if(n <= 20) sub1();
    cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}

Compilation message

sculpture.cpp: In function 'void sub1()':
sculpture.cpp:42:28: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   42 |     if((mask >> (n-1)) & 1 == 0) grp++;
      |                          ~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -