답안 #69840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69840 2018-08-21T15:27:35 Z chpipis Bali Sculptures (APIO15_sculpture) C++11
50 / 100
159 ms 1792 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int LOGV = 45;
const int MAXN = 2005;
const int INF = 1e9;

int n, a, b;
int dp[MAXN];
ll p[MAXN];

bool check(ll mask) {
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i] = INF;
        for (int j = 0; j < i; j++)
            if ((mask | (p[i] - p[j])) == mask)
                dp[i] = min(dp[i], dp[j] + 1);
    }
    return dp[n] >= a && dp[n] <= b;
}

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    scanf("%d %d %d", &n, &a, &b);
    for (int i= 1; i <= n; i++) {
        int x; scanf("%d", &x);
        p[i] = p[i - 1] + x;
    }
    ll ans = (1LL << LOGV) - 1;
    for (int i = LOGV - 1; i >= 0; i--) {
        if (check(ans - (1LL << i)))
            ans -= 1LL << i;
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:79:10: 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:81:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 3 ms 400 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 2 ms 628 KB Output is correct
11 Correct 2 ms 628 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 2 ms 784 KB Output is correct
14 Incorrect 2 ms 800 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 800 KB Output is correct
2 Correct 2 ms 800 KB Output is correct
3 Correct 3 ms 800 KB Output is correct
4 Correct 2 ms 800 KB Output is correct
5 Correct 2 ms 800 KB Output is correct
6 Correct 2 ms 800 KB Output is correct
7 Correct 2 ms 800 KB Output is correct
8 Correct 2 ms 800 KB Output is correct
9 Correct 2 ms 800 KB Output is correct
10 Correct 3 ms 800 KB Output is correct
11 Correct 3 ms 800 KB Output is correct
12 Correct 2 ms 804 KB Output is correct
13 Correct 2 ms 804 KB Output is correct
14 Incorrect 2 ms 828 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 828 KB Output is correct
2 Correct 2 ms 828 KB Output is correct
3 Correct 2 ms 828 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 828 KB Output is correct
6 Correct 2 ms 828 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 856 KB Output is correct
9 Correct 2 ms 856 KB Output is correct
10 Correct 2 ms 856 KB Output is correct
11 Correct 2 ms 856 KB Output is correct
12 Correct 2 ms 856 KB Output is correct
13 Correct 2 ms 896 KB Output is correct
14 Correct 3 ms 900 KB Output is correct
15 Correct 3 ms 900 KB Output is correct
16 Correct 2 ms 900 KB Output is correct
17 Correct 2 ms 900 KB Output is correct
18 Correct 3 ms 900 KB Output is correct
19 Correct 3 ms 920 KB Output is correct
20 Correct 2 ms 920 KB Output is correct
21 Correct 2 ms 928 KB Output is correct
22 Correct 2 ms 928 KB Output is correct
23 Correct 3 ms 928 KB Output is correct
24 Correct 3 ms 928 KB Output is correct
25 Correct 3 ms 944 KB Output is correct
26 Correct 3 ms 944 KB Output is correct
27 Correct 3 ms 960 KB Output is correct
28 Correct 3 ms 960 KB Output is correct
29 Correct 4 ms 964 KB Output is correct
30 Correct 3 ms 964 KB Output is correct
31 Correct 3 ms 972 KB Output is correct
32 Correct 3 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 3 ms 972 KB Output is correct
3 Correct 2 ms 972 KB Output is correct
4 Correct 2 ms 972 KB Output is correct
5 Correct 3 ms 972 KB Output is correct
6 Correct 2 ms 1128 KB Output is correct
7 Correct 3 ms 1128 KB Output is correct
8 Correct 2 ms 1128 KB Output is correct
9 Correct 3 ms 1128 KB Output is correct
10 Correct 3 ms 1128 KB Output is correct
11 Correct 2 ms 1128 KB Output is correct
12 Correct 3 ms 1128 KB Output is correct
13 Correct 3 ms 1128 KB Output is correct
14 Incorrect 3 ms 1128 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1128 KB Output is correct
2 Correct 2 ms 1128 KB Output is correct
3 Correct 2 ms 1128 KB Output is correct
4 Correct 2 ms 1128 KB Output is correct
5 Correct 3 ms 1128 KB Output is correct
6 Correct 2 ms 1128 KB Output is correct
7 Correct 2 ms 1128 KB Output is correct
8 Correct 2 ms 1128 KB Output is correct
9 Correct 2 ms 1128 KB Output is correct
10 Correct 2 ms 1128 KB Output is correct
11 Correct 2 ms 1128 KB Output is correct
12 Correct 3 ms 1128 KB Output is correct
13 Correct 3 ms 1128 KB Output is correct
14 Correct 2 ms 1128 KB Output is correct
15 Correct 2 ms 1128 KB Output is correct
16 Correct 2 ms 1132 KB Output is correct
17 Correct 3 ms 1132 KB Output is correct
18 Correct 2 ms 1132 KB Output is correct
19 Correct 3 ms 1132 KB Output is correct
20 Correct 2 ms 1132 KB Output is correct
21 Correct 2 ms 1132 KB Output is correct
22 Correct 3 ms 1132 KB Output is correct
23 Correct 2 ms 1152 KB Output is correct
24 Correct 2 ms 1152 KB Output is correct
25 Correct 2 ms 1152 KB Output is correct
26 Correct 3 ms 1152 KB Output is correct
27 Correct 2 ms 1152 KB Output is correct
28 Correct 2 ms 1180 KB Output is correct
29 Correct 3 ms 1216 KB Output is correct
30 Correct 2 ms 1228 KB Output is correct
31 Correct 2 ms 1228 KB Output is correct
32 Correct 2 ms 1228 KB Output is correct
33 Correct 2 ms 1240 KB Output is correct
34 Correct 2 ms 1240 KB Output is correct
35 Correct 2 ms 1240 KB Output is correct
36 Correct 2 ms 1240 KB Output is correct
37 Correct 3 ms 1252 KB Output is correct
38 Correct 3 ms 1256 KB Output is correct
39 Correct 3 ms 1256 KB Output is correct
40 Correct 3 ms 1264 KB Output is correct
41 Correct 3 ms 1388 KB Output is correct
42 Correct 3 ms 1388 KB Output is correct
43 Correct 2 ms 1388 KB Output is correct
44 Correct 3 ms 1388 KB Output is correct
45 Correct 3 ms 1388 KB Output is correct
46 Correct 3 ms 1388 KB Output is correct
47 Correct 3 ms 1388 KB Output is correct
48 Correct 3 ms 1388 KB Output is correct
49 Correct 3 ms 1388 KB Output is correct
50 Correct 4 ms 1388 KB Output is correct
51 Correct 3 ms 1388 KB Output is correct
52 Correct 13 ms 1388 KB Output is correct
53 Correct 21 ms 1388 KB Output is correct
54 Correct 38 ms 1448 KB Output is correct
55 Correct 43 ms 1448 KB Output is correct
56 Correct 154 ms 1448 KB Output is correct
57 Correct 146 ms 1448 KB Output is correct
58 Correct 123 ms 1456 KB Output is correct
59 Correct 123 ms 1580 KB Output is correct
60 Correct 119 ms 1580 KB Output is correct
61 Correct 3 ms 1608 KB Output is correct
62 Correct 23 ms 1608 KB Output is correct
63 Correct 35 ms 1608 KB Output is correct
64 Correct 31 ms 1608 KB Output is correct
65 Correct 67 ms 1608 KB Output is correct
66 Correct 95 ms 1728 KB Output is correct
67 Correct 129 ms 1728 KB Output is correct
68 Correct 117 ms 1784 KB Output is correct
69 Correct 159 ms 1792 KB Output is correct