QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#352268#8276. Code Congestionberarchegas#WA 2ms4620kbC++201.9kb2024-03-13 06:15:572024-03-13 06:15:57

Judging History

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

  • [2024-03-13 06:15:57]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4620kb
  • [2024-03-13 06:15:57]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int MOD = 998244353;
const int MAXN = 2e2 + 5;
const int MAXT = 3e5 + 10;
const ll INF = 2e18;

int a[MAXN], t[MAXN];

int dp[MAXN][MAXT], sp[MAXN][MAXT];

ll pot[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    pot[0] = 1;
    for(int i = 1; i < MAXN; i++) {
        pot[i] = pot[i - 1] * 2;
        pot[i] %= MOD;
    }
    int n, tot;
    cin >> n >> tot;
    ll resp = 0;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        cin >> t[i];
        for(int j = 0; j + t[i] <= tot; j++) {
            dp[i][j + t[i]] += dp[i - 1][j];
            dp[i][j + t[i]] %= MOD;
            resp += (dp[i - 1][j] * a[i]) % MOD * pot[n - i];
            resp %= MOD;
        }
        for(int j = 0; j <= tot; j++) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] %= MOD;
        }
    }
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= tot; j++) {
            dp[i][j] = 0;
        }
    }
    dp[n + 1][0] = 1;
    for(int i = n; i >= 1; i--) {
        for(int j = 0; j + t[i] <= tot; j++) {
            dp[i][j + t[i]] += dp[i + 1][j];
            dp[i][j + t[i]] %= MOD;
        }
        for(int j = 0; j <= tot; j++) {
            dp[i][j] += dp[i + 1][j];
            dp[i][j] %= MOD;
        }
    }
    int sp = 0;
    for(int i = 1; i <= n; i++) {
        sp += t[i];
        ll mn = 0;
        for(int j = 0; j + sp <= tot; j++) {
            mn += dp[i + 1][j];
            mn %= MOD;
        }
        resp += (mn * a[i]) % MOD * pot[i - 1];
        resp %= MOD;    
    }
    cout << resp << '\n';
    return 0;
}

詳細信息

Test #1:

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

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: 3660kb

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: 1ms
memory: 3776kb

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: 3800kb

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: 3816kb

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: 0
Accepted
time: 2ms
memory: 4608kb

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:

602403195

result:

ok 1 number(s): "602403195"

Test #7:

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

input:

198 87
276373 259622 211541 127475 41483 45243 254828 92569 120672 280027 180073 248960 25052 110553 136460 102137 166179 165627 29260 33966 121236 34304 67399 250912 104260 114026 261774 159285 218100 110269 112808 224799 170009 150816 34232 290942 52872 176861 177679 36123 92008 39070 265659 25497...

output:

37305465

result:

wrong answer 1st numbers differ - expected: '605480487', found: '37305465'