QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637289#7304. Coins 2heigeWA 0ms3720kbC++14993b2024-10-13 12:01:182024-10-13 12:01:20

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 12:01:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3720kb
  • [2024-10-13 12:01:18]
  • 提交

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];
void work() {
    sum = 0; cnt = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i]; sum += a[i] * i;
        if (a[i]) x = y, y = i;
    }
    int hg = min((x == 0 ? y * y : x * y), sum);
    if (hg == 0) {cout << 1 << '\n'; return;}
    dp[0] = 1;
    for (int i = 1; i <= 2 * hg; i++) dp[i] = 0;
    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 << endl;
}
signed main() {
    // freopen("c.in", "r", stdin);
    // freopen("c.out", "w", stdout);
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    while (cin >> n) work();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3720kb

input:

3
0 1 2
3
0 2 3

output:

6
11

result:

wrong answer 2nd numbers differ - expected: '12', found: '11'