QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506162#1247. Pop musicRainPPRWA 0ms3608kbC++231.8kb2024-08-05 15:45:572024-08-05 15:45:57

Judging History

This is the latest submission verdict.

  • [2024-08-05 15:45:57]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3608kb
  • [2024-08-05 15:45:57]
  • Submitted

answer

#ifndef M_DEBUG
#define NDEBUG 1
#define FAST_IO 1
#define D(x) ({ void(0); })
#else
#define D(x) ({ cerr << "| DEBUG #" << __LINE__ << " IN " << __FUNCTION__ << "() \t| \t" << #x << " = \t[" << (x) << "]\n"; void(0); })
#endif

#include <bits/stdc++.h>

#ifdef FAST_IO
#define endl "\n"
#endif

using namespace std;

// -----------------------------------------------------------------------------

#define AWA 2

using ll = long long;

#define int ll

constexpr int N = 210;
constexpr ll INF = 1e9;

ll n, m, a[N], s[N];

ll mem[65][N][N][2];
bool vis[65][N][N][2];

ll dfs(int i, int l, int r, bool limit) {
    if (i == 0) {
        return 0;
    }
    if (l == r) {
        if (!limit) return a[l];
        return __builtin_popcount(m & ((1 << (i + 1)) - 1)) * a[l];
    }
    ll res = -INF;
    if (!limit || ((m >> i) & 1)) {
        for (int k = l; k < r; ++k)
            res = max(res, dfs(i - 1, l, k, 0) + dfs(i - 1, k + 1, r, limit) + s[r] - s[k]);
    }
    else {
        res = dfs(i - 1, l, r, limit);
    }
    return res;
}

ll Main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> a[i], s[i] = s[i - 1] + a[i];
    return dfs(64, 1, n, 1);
}

// -----------------------------------------------------------------------------

signed main() {
    #ifdef FAST_IO
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    #endif
    #if AWA == 0

    #elif AWA == 1
    Main();

    #elif AWA == 2
    cout << Main() << endl;

    #elif AWA == 3
    int T; cin >> T;
    while (T--) Main();

    #elif AWA == 4
    int T; cin >> T;
    while (T--) cout << Main() << endl;

    #elif AWA == 5
    int T; cin >> T;
    while (T--) cout << Main() << " ";
    cout << endl;

    #else
    __builtin_unreachable();
    #endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

3 5
2 -1 3

output:

9

result:

ok answer is '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3 2
1 1 -1

output:

0

result:

ok answer is '0'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

6 11
-75 19 1 72 106 170

output:

1179

result:

wrong answer expected '1012', found '1179'