QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#709099 | #8276. Code Congestion | lichenyu_ac | WA | 2ms | 11828kb | C++14 | 953b | 2024-11-04 11:30:22 | 2024-11-04 11:30:22 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=3e5+10,mod=998244353;
int n,m,s[N],a[N],t[N];
ll Pow[N],f[N],ans;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=n;i++)scanf("%d",&t[i]),s[i]=t[i];
for(int i=2;i<=n;i++)s[i]+=s[i-1];
Pow[0]=1;
for(int i=1;i<=n;i++)Pow[i]=Pow[i-1]*2;
f[0]=1;
for(int i=1;i<=n;i++){
ll sum=0;
for(int j=m;j>=t[i];j--){
sum+=f[j-t[i]];
f[j]+=f[j-t[i]];
}
ans=(ans+sum*a[i]%mod*Pow[n-i]%mod)%mod;
}
memset(f,0,sizeof(f));
f[0]=1;
for(int i=n;i;i--){
ll sum=0;
for(int j=m-s[i];j>=0;j--){
sum+=f[j];
}
for(int j=m;j>=t[i];j--){
f[j]+=f[j-t[i]];
}
ans=(ans+sum*a[i]*Pow[i-1]%mod)%mod;
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 10636kb
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: 10720kb
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: 8556kb
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: 10792kb
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: 8412kb
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: 11828kb
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:
-377046374
result:
wrong answer 1st numbers differ - expected: '602403195', found: '-377046374'