답안 #469399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469399 2021-08-31T21:27:55 Z chienyu_xiong Bali Sculptures (APIO15_sculpture) C++17
21 / 100
5 ms 332 KB
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second

#define pb push_back
#define mp make_pair

#define int long long

#define pii pair<int, int>

#define all(_) begin(_), end(_)

#define smx(y, x) ((y) = max(x, y))
#define smn(y, x) ((y) = min(x, y))

void setIO() {
    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int N = 2e3 + 5;
const int M = 1e1 + 2;
const int K = 3e5 + 0;

const int inf = 9e17;
const int mod = 1e9 + 7; 

int xyz = 1; // test cases

int n, t, m;

int arr[N];

bool dp[2][N];

bool chk(int msk) {
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        dp[0][i] = 0;

    for (int j = 1; j <= m; j++) {
        int p = j & 1;
        int o = p ^ 1;

        for (int i = 1; i <= n; i++) {
            int sum = 0;

            dp[p][i] = false;
            for (int k = i; k >= 1; k--)
                sum += arr[k], dp[p][i] |= (sum & msk) == sum && dp[o][k - 1];
        }

        if (j >= t && dp[p][n]) return true;

        /* for (int i = 1; i <= n; i++) cout << dp[p][i] << " "; cout << endl; */
    }

    return false;
}

void run() {
    cin >> n >> t >> m;

    for (int i = 1; i <= n; i++)
        cin >> arr[i];

    int msk = (1 << 30) - 1;
    for (int i = 29; i >= 0; i--) {
        if (chk(msk ^ (1 << i))) {
            msk ^= (1 << i);
        }
    }

    cout << msk << endl;
}

signed main() {
    setIO();

    while (xyz--)
        run();

#ifdef LOCAL
    cin.clear(); cout.flush(); system("pause");
#endif

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Incorrect 0 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 3 ms 204 KB Output is correct
28 Correct 5 ms 204 KB Output is correct
29 Correct 5 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 3 ms 204 KB Output is correct
32 Correct 4 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 1 ms 316 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Incorrect 0 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -