QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617035#8276. Code Congestionpengpeng_fudan#WA 2ms6264kbC++232.0kb2024-10-06 13:37:372024-10-06 13:37:37

Judging History

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

  • [2024-10-06 13:37:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6264kb
  • [2024-10-06 13:37:37]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int mod = 998244353;

const int N = 210, T = 3e5 + 10;
int n, m;
int a[N], t[N], s[N];
int pw2[N];
int st[N];
int f[T], g[T];

int add(int x, int y) {
    return x + y >= mod ? x + y - mod : x + y;
}

int main() {
    scanf("%d%d", &n, &m);
    pw2[0] = 1;
    for (int i = 1; i <= n; ++i) {
        pw2[i] = add(pw2[i - 1], pw2[i - 1]);
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; ++i) {
        s[i] = add(s[i - 1], a[i]);
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &t[i]);
        st[i] = st[i - 1] + t[i];
    }
    int ans = 0;
    if (st[n] <= m) {
        ans = 1ll * s[n] * pw2[n] % mod;
        printf("%d\n", ans);
        return 0;
    }
    // cerr << 1 << '\n';
    // return 0;
    f[0] = 1;
    for (int i = n; i; --i) {
        if (st[i - 1] <= m) {
            for (int j = 0; j <= m; ++j) {
                if (j + st[i - 1] <= m && j + st[i - 1] + t[i] > m) {
                    ans = add(ans, 1ll * s[i - 1] * pw2[i - 1] % mod * f[j]);
                    ans = add(ans, 1ll * pw2[i - 1] * g[j] % mod);
                }
            }
        }
        for (int j = m; j >= t[i]; --j) {
            f[j] = add(f[j - t[i]], f[j]);
            g[j] = add(g[j - t[i]], g[j]);
            g[j] = add(g[j], 1ll * f[j - t[i]] * a[i] % mod);
        }
    }
    // cerr << 1 << '\n';
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    f[0] = 1;
    for (int i = 1; i <= n; ++i) {
        // cerr << i << '\n';
        for (int j = 0; j <= m; ++j) {
            if (j + t[i] > m) {
                ans = add(ans, 1ll * g[j] * pw2[n - i] % mod);
            }
        }
        for (int j = m; j >= t[i]; --j) {
            f[j] = add(f[j - t[i]], f[j]);
            g[j] = add(g[j - t[i]], g[j]);
            g[j] = add(g[j], 1ll * f[j - t[i]] * a[i] % mod);
        }
    }
    // cerr 
    printf("%d\n", ans);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 6208kb

input:

3 3
2 3 4
1 2 2

output:

40

result:

ok 1 number(s): "40"

Test #2:

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

input:

13 96
56231 258305 150103 164646 232643 37457 239584 192517 167805 215281 159832 98020 141006
54 1 38 1 4 1 4 11 1 4 8 22 1

output:

745634757

result:

ok 1 number(s): "745634757"

Test #3:

score: 0
Accepted
time: 2ms
memory: 6264kb

input:

14 86
205026 38691 58462 59767 205360 152715 7879 105238 33507 280429 54906 248241 102327 202931
1 49 1 1 5 12 1 5 9 18 1 1 3 32

output:

310231569

result:

ok 1 number(s): "310231569"

Test #4:

score: 0
Accepted
time: 0ms
memory: 6104kb

input:

14 85
82111 267744 229782 32542 260127 152775 1364 293699 23965 242667 264864 219673 189482 12945
1 5 1 1 2 1 38 14 1 3 4 1 21 53

output:

745175834

result:

ok 1 number(s): "745175834"

Test #5:

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

input:

15 94
119505 80865 95965 30047 68261 120903 113180 192738 220899 279742 32609 275645 38640 213859 282516
1 1 8 15 1 3 1 38 6 1 23 57 1 5 79

output:

970187257

result:

ok 1 number(s): "970187257"

Test #6:

score: -100
Wrong Answer
time: 2ms
memory: 6192kb

input:

200 91
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

155038304

result:

wrong answer 1st numbers differ - expected: '602403195', found: '155038304'