QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#685128 | #8276. Code Congestion | Joyeuse_Ordre# | WA | 0ms | 1660kb | C++14 | 1.2kb | 2024-10-28 17:49:15 | 2024-10-28 17:49:15 |
Judging History
answer
#include <cstdio>
const int N = 205, M = 2e5 + 5, P = 998244353;
int n, T, a[N], t[N], p[N], pow[N];
int dp1[M], dp2[N], st[N], ans;
int main() {
scanf("%d%d", &n, &T);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
for (int i = 1; i <= n; i++) scanf("%d", t + i), st[i] = st[i - 1] + t[i];
pow[0] = 1;
for (int i = 1; i <= n; i++) pow[i] = (pow[i - 1] * 2ll) % P;
dp1[0] = dp2[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= T - t[i]; j++) {
p[i] += 1ll * dp1[j] * pow[n - i] % P;
// printf("dp1[%d] = %d\n", j, dp1[j]);
// printf("p[%d] += %d * %d = %lld\n", i, dp1[j], pow[n - i], 1ll * dp1[j] * pow[n - i] % P);
}
for (int j = T; j >= t[i]; j--)
dp1[j] += dp1[j - t[i]];
// printf("%d%c", p[i], " \n"[i == n]);
}
for (int i = n; i >= 1; i--) {
for (int j = 0; j <= T - st[i]; j++)
p[i] += 1ll * dp2[j] * pow[i - 1] % P;
for (int j = T; j >= t[i]; j--)
dp2[j] += dp2[j - t[i]];
}
for (int i = 1; i <= n; i++) ans = (ans + 1ll * p[i] * a[i] % P) % P;
printf("%d\n", ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1624kb
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: 1656kb
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: 0ms
memory: 1660kb
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: 1624kb
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: 0ms
memory: 1648kb
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: 0ms
memory: 1584kb
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:
567802170
result:
wrong answer 1st numbers differ - expected: '602403195', found: '567802170'