답안 #251977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251977 2020-07-23T10:58:20 Z IgorI Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 896 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 2005;

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

signed main()
{
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    forn(i, n) cin >> x[i];
    vector<ll> p(n + 1);
    for (int i = 1; i <= n; i++) p[i] = x[i - 1] + p[i - 1];
    ll ans = (1ll << 60) - 1;
    for (int j = 59; j >= 0; j--)
    {
        if (check(n, a, b, p, ans - (1ll << j)))
        {
            ans -= (1ll << j);
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 1 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 2 ms 328 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 3 ms 256 KB Output is correct
30 Correct 4 ms 256 KB Output is correct
31 Correct 6 ms 256 KB Output is correct
32 Correct 6 ms 256 KB Output is correct
33 Correct 6 ms 256 KB Output is correct
34 Correct 6 ms 256 KB Output is correct
35 Correct 7 ms 256 KB Output is correct
36 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 6 ms 256 KB Output is correct
19 Correct 6 ms 256 KB Output is correct
20 Correct 7 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 256 KB Output is correct
24 Correct 6 ms 256 KB Output is correct
25 Correct 9 ms 384 KB Output is correct
26 Correct 12 ms 256 KB Output is correct
27 Correct 18 ms 384 KB Output is correct
28 Correct 19 ms 384 KB Output is correct
29 Correct 20 ms 384 KB Output is correct
30 Correct 21 ms 384 KB Output is correct
31 Correct 21 ms 384 KB Output is correct
32 Correct 22 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 1 ms 256 KB Output is correct
35 Correct 1 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Correct 2 ms 256 KB Output is correct
39 Correct 4 ms 256 KB Output is correct
40 Correct 4 ms 256 KB Output is correct
41 Correct 6 ms 256 KB Output is correct
42 Correct 5 ms 256 KB Output is correct
43 Correct 6 ms 384 KB Output is correct
44 Correct 6 ms 384 KB Output is correct
45 Correct 8 ms 256 KB Output is correct
46 Correct 6 ms 256 KB Output is correct
47 Correct 5 ms 256 KB Output is correct
48 Correct 10 ms 384 KB Output is correct
49 Correct 12 ms 384 KB Output is correct
50 Correct 18 ms 384 KB Output is correct
51 Correct 31 ms 384 KB Output is correct
52 Correct 28 ms 384 KB Output is correct
53 Correct 22 ms 384 KB Output is correct
54 Correct 19 ms 384 KB Output is correct
55 Correct 22 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 7 ms 384 KB Output is correct
58 Correct 9 ms 384 KB Output is correct
59 Correct 18 ms 384 KB Output is correct
60 Correct 11 ms 384 KB Output is correct
61 Correct 11 ms 384 KB Output is correct
62 Correct 12 ms 384 KB Output is correct
63 Correct 13 ms 384 KB Output is correct
64 Correct 18 ms 384 KB Output is correct
65 Correct 5 ms 256 KB Output is correct
66 Correct 5 ms 256 KB Output is correct
67 Correct 8 ms 384 KB Output is correct
68 Correct 9 ms 384 KB Output is correct
69 Correct 10 ms 384 KB Output is correct
70 Correct 11 ms 384 KB Output is correct
71 Correct 10 ms 384 KB Output is correct
72 Correct 13 ms 384 KB Output is correct
73 Correct 16 ms 396 KB Output is correct
74 Correct 13 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 3 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 5 ms 256 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 6 ms 256 KB Output is correct
29 Correct 6 ms 256 KB Output is correct
30 Correct 6 ms 256 KB Output is correct
31 Correct 7 ms 256 KB Output is correct
32 Correct 7 ms 256 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 256 KB Output is correct
35 Correct 16 ms 384 KB Output is correct
36 Correct 12 ms 384 KB Output is correct
37 Correct 18 ms 384 KB Output is correct
38 Correct 20 ms 384 KB Output is correct
39 Correct 20 ms 384 KB Output is correct
40 Correct 20 ms 384 KB Output is correct
41 Correct 25 ms 384 KB Output is correct
42 Correct 22 ms 512 KB Output is correct
43 Correct 3 ms 256 KB Output is correct
44 Correct 7 ms 384 KB Output is correct
45 Correct 9 ms 384 KB Output is correct
46 Correct 11 ms 384 KB Output is correct
47 Correct 11 ms 384 KB Output is correct
48 Correct 10 ms 384 KB Output is correct
49 Correct 12 ms 384 KB Output is correct
50 Correct 12 ms 384 KB Output is correct
51 Correct 12 ms 384 KB Output is correct
52 Correct 298 ms 596 KB Output is correct
53 Correct 480 ms 580 KB Output is correct
54 Correct 901 ms 752 KB Output is correct
55 Correct 865 ms 752 KB Output is correct
56 Execution timed out 1096 ms 896 KB Time limit exceeded
57 Halted 0 ms 0 KB -