QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612986#9436. Some Sum of Subsetucup-team1004#WA 1ms4080kbC++141.6kb2024-10-05 13:23:532024-10-05 13:23:59

Judging History

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

  • [2024-10-05 13:23:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4080kb
  • [2024-10-05 13:23:53]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=3000+5,M=100+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,A[N];
ll f[N],C[N][N],ans[N];
void Solve(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;i++) for(int j=C[i][0]=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	f[0]=1;
	for(int i=n;i;i--){
		ll tot=0;
		for(int j=0;j<m;j++) if(j+A[i]>=m) tot+=f[j];
		tot%=mod;
		for(int j=0;j<i;j++) ans[j]+=tot*C[i-1][j]%mod;
		for(int j=m;~j;j--) (f[j+A[i]]+=f[j])%=mod;
	}
	for(int i=n;~i;i--) (ans[i]+=ans[i+1])%=mod;
	for(int i=0;i<=n;i++){
		printf("%lld\n",ans[i]);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4028kb

input:

4 7
3 1 5 2

output:

6
4
1
0
0

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

1 5
7

output:

1
0

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

9 18
1 9 5 6 2 7 1 4 8

output:

346
309
230
126
46
10
1
0
0
0

result:

ok 10 tokens

Test #4:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

1 1467
556

output:

0
0

result:

ok 2 tokens

Test #5:

score: 0
Accepted
time: 0ms
memory: 4020kb

input:

1 1753
2514

output:

1
0

result:

ok 2 tokens

Test #6:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

1 1182
1182

output:

1
0

result:

ok 2 tokens

Test #7:

score: 0
Accepted
time: 0ms
memory: 4080kb

input:

2 1741
955 835

output:

1
0
0

result:

ok 3 tokens

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 4036kb

input:

2 1481
2004 1570

output:

2
1
0

result:

wrong answer 1st words differ - expected: '3', found: '2'