QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#653567#8276. Code CongestionshiqiaqiayaWA 0ms3576kbC++201.4kb2024-10-18 20:18:112024-10-18 20:18:12

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

constexpr int mod = 998244353;

void solve() {
    int n, T, ans = 0;
    cin >> n >> T;

    vector<int> a(n + 1), t(n + 1), pre(n + 1), fact(n + 1, 1);

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        (fact[i] = fact[i - 1] * 2) %= mod;
    }
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
        pre[i] = pre[i - 1] + t[i];
    }

    vector<int> dp(T + 1, -1), sum(T + 1);

    dp[0] = 0;

    for (int i = n; i; i--) {
        if (pre[i] <= T) {
            (ans += fact[i - 1] * (pre[i] + sum[T])) %= mod;
        }
        vector<int> dpn = dp;

        for (int j = t[i]; j <= T; j++) {
            if (dp[j - t[i]] != -1) {
                if (dpn[j] == -1) {
                    (dpn[j] = dp[j - t[i]] + a[i]) %= mod;
                } else {
                    (dpn[j] += dp[j - t[i]] + a[i]) %= mod;
                }
            }
        }

        swap(dp, dpn);

        sum[0] = 0;
        for (int j = 1; j <= T; j++) {
            if (dp[j] != -1) {
                (sum[j] = sum[j - 1] + dp[j]) %= mod;
            } else {
                sum[j] = sum[j - 1];
            }
        }
    }

    (ans += sum[T]) %= mod;

    cout << ans << "\n";
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    // cin >> T;
    while (T--) solve();
    return 0 ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

3 3
2 3 4
1 2 2

output:

40

result:

ok 1 number(s): "40"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3568kb

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:

904392368

result:

wrong answer 1st numbers differ - expected: '745634757', found: '904392368'