QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#355514 | #8276. Code Congestion | maxplus# | WA | 126ms | 6052kb | C++20 | 1.3kb | 2024-03-16 19:04:01 | 2024-03-16 19:04:01 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC target "abm,bmi,bmi2"
using namespace std;
constexpr int N = 2e2, T = 3e5 + 1, mod = 998244353;
auto& mul(auto&& a, auto b) { return a = a * (uint64_t)b % mod; }
auto& add(auto&& a, auto b) { return a -= (a += b) >= mod? mod: 0; }
int a[N], t[N], pw2[N];
array<int, 2> dp[T];
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, tl, ans{}; cin >> n >> tl;
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i) cin >> t[i];
fill(&dp[0][0], &dp[T][0], 0);
dp[0] = {1, 0};
for (int i = 0, p = 1; i < n; ++i) pw2[i] = p, add(p, p);
for (int i = 0; i < n; ++i) {
for (int j = tl - t[i]; ++j <= tl; ) ans = (ans + dp[j][1] * (uint64_t)pw2[n - i - 1]) % mod;
for (int j = tl - t[i]; ~j; --j) dp[j + t[i]] = {add(+dp[j + t[i]][0], dp[j][0]), (dp[j + t[i]][1] + dp[j][1] + a[i] * (uint64_t)dp[j][0]) % mod};
}
fill(&dp[0][0], &dp[T][0], 0);
dp[0] = {1, 0};
for (int i = n; i--; ) {
int pt = accumulate(t, t + i, 0), pa = accumulate(a, a + i, 0);
for (int j = max(tl - pt - t[i], -1); ++j <= tl - pt; ) ans = (ans + (dp[j][1] + dp[j][0] * (uint64_t)pa) % mod * pw2[i]) % mod;
for (int j = tl - t[i]; ~j; --j) dp[j + t[i]] = {add(+dp[j + t[i]][0], dp[j][0]), (dp[j + t[i]][1] + dp[j][1] + a[i] * (uint64_t)dp[j][0]) % mod};
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5904kb
input:
3 3 2 3 4 1 2 2
output:
40
result:
ok 1 number(s): "40"
Test #2:
score: 0
Accepted
time: 0ms
memory: 6008kb
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: 6028kb
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: 6000kb
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: 6052kb
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: 6008kb
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: 0
Accepted
time: 0ms
memory: 5912kb
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:
605480487
result:
ok 1 number(s): "605480487"
Test #8:
score: -100
Wrong Answer
time: 126ms
memory: 5944kb
input:
198 234111 89712 73706 49851 196942 284937 252036 155683 1073 160017 24302 1736 21240 97245 116054 17583 258181 102901 54151 14410 251885 121370 135369 278761 195054 259593 292654 222660 193579 111738 119045 14083 214343 1531 298888 25144 88309 170939 62023 113276 169190 31076 65869 121858 158901 89...
output:
0
result:
wrong answer 1st numbers differ - expected: '762578553', found: '0'