QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#546056#6355. 5lifanTL 1548ms18984kbC++14520b2024-09-03 19:20:382024-09-03 19:20:42

Judging History

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

  • [2024-09-03 19:20:42]
  • 评测
  • 测评结果:TL
  • 用时:1548ms
  • 内存:18984kb
  • [2024-09-03 19:20:38]
  • 提交

answer

// 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 + 5;
int n , S , a[MAXN];
ll ans;
bitset<MAXN> dp[MAXN];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> S;
	for (int i = 1 ; i <= n ; i ++) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1 ; i <= n ; i ++) {
		for (int j = i - 1 ; ~j ; j --) {
			dp[j + 1] |= (dp[j] << a[i]);
		}
	}
	for (int i = 0 ; i <= n ; i ++) ans += dp[i].count();
	cout << ans;
}
/*
7 9
0 0 0 1 1 2 5
*/

詳細信息

Test #1:

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

input:

7 9
0 0 0 1 1 2 5

output:

42

result:

ok 1 number(s): "42"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3748kb

input:

10 33
9 9 8 1 1 1 1 1 1 1

output:

48

result:

ok 1 number(s): "48"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

10 14
2 4 4 1 0 1 0 1 0 1

output:

81

result:

ok 1 number(s): "81"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

10 14
3 5 3 0 1 0 1 0 1 0

output:

87

result:

ok 1 number(s): "87"

Test #5:

score: 0
Accepted
time: 2ms
memory: 4064kb

input:

40 50
1 1 1 1 3 3 0 3 1 1 0 0 2 1 0 0 1 0 0 2 7 1 2 1 3 0 2 2 3 1 1 0 0 2 0 1 1 0 1 1

output:

1067

result:

ok 1 number(s): "1067"

Test #6:

score: 0
Accepted
time: 1548ms
memory: 18984kb

input:

1200 1000
1 1 2 3 0 1 0 0 1 1 0 2 3 0 1 2 0 0 1 0 4 1 1 2 1 1 0 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 2 0 4 0 3 1 6 0 1 1 0 0 0 0 4 0 0 0 0 0 0 1 0 0 1 7 1 1 1 0 1 0 1 0 1 1 0 0 1 1 1 3 0 1 0 1 0 0 1 1 2 2 0 1 1 0 0 1 4 1 2 0 0 0 3 0 0 2 1 0 2 0 0 0 1 1 0 0 2 0 0 0 0 1 1 0 1 0 1 6 1 1 ...

output:

737899

result:

ok 1 number(s): "737899"

Test #7:

score: -100
Time Limit Exceeded

input:

12000 10000
1 1 0 0 1 0 2 1 3 0 0 1 0 3 1 1 0 1 1 1 1 1 2 1 0 1 2 1 0 1 2 0 5 1 1 1 0 2 0 1 0 1 0 3 2 0 1 0 1 1 2 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 4 0 1 3 1 0 0 1 0 1 2 1 0 0 1 1 0 2 1 1 0 1 0 1 0 0 2 1 1 3 0 1 1 1 0 0 0 1 1 1 0 3 0 0 0 2 0 0 0 1 0 2 0 1 1 1 0 0 1 0 1 0 2 0 0 0 0 0 0 0 1 0 1 0 0 4 1 ...

output:


result: