QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#637277 | #7304. Coins 2 | heige | WA | 0ms | 3644kb | C++14 | 840b | 2024-10-13 11:57:41 | 2024-10-13 11:57:42 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 105;
int n, sum, cnt, x, y;
int a[maxn];
int dp[100005];
signed main() {
// freopen("c.in", "r", stdin);
// freopen("c.out", "w", stdout);
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i]; sum += a[i] * i;
if (a[i]) x = y, y = i;
}
int hg = max((x == 0 ? y * y : x * y), sum);
dp[0] = 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= min(2 * hg / i, a[i]); j++)
for (int k = 2 * hg; k >= i; k--)
dp[k] |= dp[k - i];
for (int i = 1; i <= hg; i++) cnt += dp[i];
cnt *= sum / hg;
for (int i = 1; i <= sum % hg; i++) cnt += dp[i];
cout << cnt + 1 << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3644kb
input:
3 0 1 2 3 0 2 3
output:
6
result:
wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements