답안 #506796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
506796 2022-01-12T06:58:05 Z Aldas25 Bali Sculptures (APIO15_sculpture) C++14
37 / 100
1000 ms 540 KB
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;

const int MAXN = 2100;
const ll INF = (ll)1e17;

int n, a, b;
ll y[MAXN];
ll pref[MAXN];
bool dp[MAXN][MAXN];

bool check (ll mask) {
   // cout << " mask = " << mask << endl;

    FOR(i, 0, n) FOR(g, 0, n) dp[i][g] = false;

    dp[0][0] = true;

    FOR(i, 1, n) FOR(g, 1, i) {
        FOR(j, g-1, i-1) {
            if (!dp[j][g-1]) continue;
            ll sum = pref[i]-pref[j];
            if (sum & mask) continue;
            dp[i][g] = true;
            //cout << " i = " << i << " g = " << g << " is true  for j = " << j << endl;
            break;
        }
    }

    FOR(x, a, b)
        if (dp[n][x])
            return true;
    return false;
}

int main()
{
    FAST_IO;

    cin >> n >> a >> b;
    FOR(i, 1, n) cin >> y[i];
    FOR(i, 1, n) pref[i] = pref[i-1] + y[i];

    FOR(x, 0, 2*pref[n]) {
        ll inv = ~x;
       // cout << " x = " << x << endl;
        if (check(inv)) {
            cout << x << "\n";
            return 0;
        }
    }

    return 0;
}

/*
in:
6 1 3
8 1 2 1 5 4
ans: 11

in:
6 1 6
8 1 2 1 5 4

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Execution timed out 1088 ms 204 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 320 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 13 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 16 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 4 ms 452 KB Output is correct
28 Correct 5 ms 444 KB Output is correct
29 Correct 3 ms 460 KB Output is correct
30 Correct 323 ms 512 KB Output is correct
31 Correct 7 ms 460 KB Output is correct
32 Correct 5 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Execution timed out 1095 ms 332 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Execution timed out 1095 ms 204 KB Time limit exceeded
15 Halted 0 ms 0 KB -