QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637282#7304. Coins 2heigeRE 0ms3616kbC++14946b2024-10-13 11:59:332024-10-13 11:59:34

Judging History

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

  • [2024-10-13 11:59:34]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3616kb
  • [2024-10-13 11:59:33]
  • 提交

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 = max((x == 0 ? y * y : x * y), sum);
    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 << '\n';
}
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: 100
Accepted
time: 0ms
memory: 3616kb

input:

3
0 1 2
3
0 2 3

output:

6
12

result:

ok 2 number(s): "6 12"

Test #2:

score: -100
Runtime Error

input:

1
0
15
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:


result: