답안 #25057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25057 2017-06-20T05:31:57 Z 윤교준(#1055) Bali Sculptures (APIO15_sculpture) C++11
0 / 100
0 ms 2052 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (2005)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

ll S[MAXN];
int Y[MAXN];
int N, A, B;

void input() {
    scanf("%d%d%d", &N, &A, &B);
    for(int i = 1; i <= N; i++) scanf("%d", &Y[i]);
    for(int i = 1; i <= N; i++) S[i] = S[i-1] + Y[i];
}
bool bitgood(ll a, ll b) { return (a|b) == b; }
int d1[MAXN];
bool f1(ll n) {
    fill(d1, d1+N+1, -1);
    for(int i = 1; i <= N; i++) {
        int &ret = d1[i];
        if(bitgood(S[i], n)) ret = i;
        for(int j = 1; j < i; j++) {
            if(-1 == d1[j]) continue;
            if(-1 != ret && ret <= d1[j]+1) continue;
            if(bitgood(S[i]-S[j], n)) ret = d1[j]+1;
        }
    }
    return -1 != d1[N] && d1[N] <= B;
}
bool f2(ll n) {
    return false;
}
bool f(ll n) { return 1 == A ? f1(n) : f2(n); }
ll getAns() {
    ll ret = 0;
    for(int i = 50; ~i; i--) {
        if(!f(ret + (1ll<<i) - 1)) ret += (1ll<<i);
    }
    return ret;
}
int main() {
    input();
    printf("%lld\n", getAns());
    return 0;
}

Compilation message

sculpture.cpp: In function 'void input()':
sculpture.cpp:39:32: 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:40:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= N; i++) scanf("%d", &Y[i]);
                                                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2052 KB Output is correct
2 Incorrect 0 ms 2052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2052 KB Output is correct
2 Incorrect 0 ms 2052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2052 KB Output is correct
2 Incorrect 0 ms 2052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2052 KB Output is correct
2 Incorrect 0 ms 2052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2052 KB Output is correct
2 Incorrect 0 ms 2052 KB Output isn't correct
3 Halted 0 ms 0 KB -