답안 #224895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224895 2020-04-19T04:43:23 Z Nightlight Bali Sculptures (APIO15_sculpture) C++14
0 / 100
6 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int N, A, B;
long long pre[2005];
bool dp[2005][2005];
long long tans;
bitset<2005> valid[2005];

long long ans = (1LL << 42) - 1;

bool check(int X, long long T) {
  return ((T >> X) & ~(tans >> X)) == 0;
}

bool can(int X) {
  for(int i = 1; i < N; i++) {
    for(int j = i + 1; j <= N; j++) {
      valid[i][j] = check(X, pre[j] - pre[i]);
    }
  }
  //i adalah jumlah ambil
  //j lokasi sekarang
  bitset<2005> now[2];
  for(int j = 1; j <= N; j++) {
    if(check(X, pre[j])) {
      now[1] |= valid[j];
    }
  }
  int skrg, sblm;
  for(int i = 2; i <= B; i++) {
    skrg = i & 1, sblm = !skrg;
    now[skrg] = 0;
    for(int j = i; j <= N; j++) {
      if(now[sblm][j]) {
        now[skrg] |= valid[j];
      }
    }
    if(i >= A && now[sblm][N]) return 1;  
  }
  return 0;
}

int main() {
//  freopen("inp", "r", stdin);
  scanf("%d %d %d", &N, &A, &B);
  for(int i = 1; i <= N; i++) {
    scanf("%lld", &pre[i]);
    pre[i] += pre[i - 1];
  }
  for(int i = 41; i >= 0; i--) {
    tans = ans - (1LL << i);
    if(can(i)) {
      ans -= (1LL << i);
    }
  }
  printf("%lld\n", ans);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &N, &A, &B);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &pre[i]);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 6 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -