QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#506143 | #1247. Pop music | RainPPR | WA | 0ms | 3536kb | C++23 | 1.8kb | 2024-08-05 15:40:58 | 2024-08-05 15:40:59 |
Judging History
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 = 1e18;
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 (l == r) {
if (!limit) return a[l];
return __builtin_popcount(m & ((1 << (i + 1)) - 1)) * a[l];
}
if (i == -1) {
return 0;
}
ll res = -INF;
if ((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) + 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: 3536kb
input:
3 5 2 -1 3
output:
9
result:
ok answer is '9'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3536kb
input:
3 2 1 1 -1
output:
1
result:
wrong answer expected '0', found '1'