QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637293#7304. Coins 2heigeWA 39ms3836kbC++141006b2024-10-13 12:02:212024-10-13 12:02:23

Judging History

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

  • [2024-10-13 12:02:23]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:3836kb
  • [2024-10-13 12:02:21]
  • 提交

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 = (sum <= 10000 ? sum : (x == 0 ? y * y : x * y));
    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: 100
Accepted
time: 0ms
memory: 3596kb

input:

3
0 1 2
3
0 2 3

output:

6
12

result:

ok 2 number(s): "6 12"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

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

output:

1
120000000001

result:

ok 2 number(s): "1 120000000001"

Test #3:

score: -100
Wrong Answer
time: 39ms
memory: 3836kb

input:

5
0 2 1 0 0
5
0 0 0 0 53
5
0 6 3 0 0
5
1 0 0 0 1
5
1 0 0 0 0
5
2 0 0 0 116
5
2 0 0 0 0
5
1 0 1 106 1356
5
0 2 0 0 7926
5
0 0 2 1 2004
5
1 0 0 0 1
5
0 0 0 1 5
5
0 0 0 0 0
5
0 1 32840 0 1
5
2 0 0 0 12
5
2 0 0 1 1
5
0 1 79 56770 10
5
1 0 0 1 0
5
0 1 1 2 52165
5
0 0 0 0 1
5
0 0 1 13 0
5
0 0 0 1 10
5
0 0...

output:

6
54
20
4
2
351
3
7207
23781
9027
4
12
1
85390
39
10
216001
4
247797
2
28
22
114
78
76
4
280
233
8
1
12
160932
10
2
1
1
2
108
17760
15926
237575
50022
4
104
282
43150
1687
2973
8
26110
6
4
2988
8
10
102
4
793
69
2
7624
4
169728
84
34761
3
2832
11
25
2
30836
127
31446
2
3
8
116
4
6
260
4
6
27093
4
2
...

result:

wrong answer 10th numbers differ - expected: '10027', found: '9027'