QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202838 | #2482. Storage Problems | BoulevardDust# | WA | 0ms | 3964kb | C++20 | 1.0kb | 2023-10-06 13:42:41 | 2023-10-06 13:42:41 |
Judging History
answer
#include<bits/stdc++.h>
#define N 405
#define re
#define ll long long
#define P 167772161
using namespace std;
int n,m,K,q,T;
inline void Rd(int &res){
re char c;res=0;
while(c=getchar(),c<48);
do res=(res<<3)+(res<<1)+(c^48);
while(c=getchar(),c>47);
}
int a[N],f[N][N],g[N][N];
inline void Mod(int &x){x>=P&&(x-=P);}
int main(){
Rd(n),Rd(K);
for(re int i=1;i<=n;i++)Rd(a[i]);
f[0][0]=1;
for(re int i=1;i<=n;i++){
for(re int j=0;j<=i;j++)
for(re int k=0;k<=K;k++){
Mod(g[j][k]+=f[j][k]);
if(k>=a[i]&&j>0)Mod(g[j][k]+=f[j-1][k-a[i]]);
}
for(re int j=0;j<=i;j++)
for(re int k=0;k<=K;k++)f[j][k]=g[j][k],g[j][k]=0;
}
for(re int i=1;i<=n;i++){
for(re int j=0;j<=n;j++)
for(re int k=0;k<=n;k++){
g[j][k]=f[j][k];
if(j>0&&k>=a[i])g[j][k]-=g[j-1][k-a[i]];
g[j][k]<0&&(g[j][k]+=P);
}
for(re int j=1;j<n;j++){
int res=0;
for(re int k=K-a[i]+1;k<=K;k++)Mod(res+=g[j][k]);
printf("%d",res);
putchar(j==n-1?'\n':' ');
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
3 2 1 1 2
output:
1 0 1 0 2 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
3 3 2 2 1
output:
1 1 1 1 0 0
result:
ok 3 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
3 6 6 5 2
output:
1 0 1 0 0 0
result:
wrong answer 1st lines differ - expected: '2 0', found: '1 0'