QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559862#5552. Skyscraperuser1008615 1ms4532kbC++171.2kb2024-09-12 09:59:572024-09-12 10:00:02

Judging History

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

  • [2024-09-12 10:00:02]
  • 评测
  • 测评结果:15
  • 用时:1ms
  • 内存:4532kb
  • [2024-09-12 09:59:57]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 101, M = 1e3 + 10, MOD = 1e9 + 7;

int n, L, dp[N][N][M][3], a[N];

void add(int& x, int y)
{
	(x += y) %= MOD;
}

signed main()
{
	cin >> n >> L;
	for (int i = 1; i <= n; i++) cin >> a[i];
	if (n == 1)
	{
		cout << 1;
		return 0;
	}
	sort(a + 1, a + 1 + n);
	
	dp[0][0][0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= i; j++)
			for (int l = 0; l <= L; l++)
				for (int k = 0; k <= 2; k++)
				{
//					printf("dp(%lld, %lld, %lld, %lld) = %lld\n", i, j, l, k, dp[i][j][l][k]);
					
					int d = a[i + 1] - a[i];
					int nxt = l + d * (2 * j - k);
					if (nxt > L) continue;
					
					add(dp[i + 1][j + 1][nxt][k], dp[i][j][l][k] * (j + 1 - k));
					if (k < 2) add(dp[i + 1][j + 1][nxt][k + 1], dp[i][j][l][k] * (2 - k));
					if (j > 0) add(dp[i + 1][j - 1][nxt][k], dp[i][j][l][k] * (j - 1));
					add(dp[i + 1][j][nxt][k], dp[i][j][l][k] * (2 * j - k));
					if (k < 2) add(dp[i + 1][j][nxt][k + 1], dp[i][j][l][k] * (2 - k));
				}
	int ans = 0;
	for (int l = 0; l <= L; l++) (ans += dp[n][1][l][2]) %= MOD;
	cout << ans;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3532kb

input:

1 1
8

output:

1

result:

ok single line: '1'

Test #2:

score: 5
Accepted
time: 0ms
memory: 3552kb

input:

2 6
10 4

output:

2

result:

ok single line: '2'

Test #3:

score: 5
Accepted
time: 0ms
memory: 3712kb

input:

3 11
9 1 3

output:

4

result:

ok single line: '4'

Test #4:

score: 5
Accepted
time: 0ms
memory: 3808kb

input:

6 94
45 79 24 10 41 66

output:

12

result:

ok single line: '12'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 4532kb

input:

8 945
493 43 988 504 328 730 841 613

output:

34

result:

wrong answer 1st lines differ - expected: '2', found: '34'

Subtask #2:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 1ms
memory: 4208kb

input:

12 63
8 2 6 3 11 9 1 12 4 5 10 7

output:

472261248

result:

ok single line: '472261248'

Test #12:

score: 15
Accepted
time: 0ms
memory: 4316kb

input:

14 96
17 36 98 27 13 68 11 34 80 50 22 73 94 37

output:

44

result:

ok single line: '44'

Test #13:

score: 15
Accepted
time: 1ms
memory: 4180kb

input:

14 45
6 9 12 15 18 2 14 5 11 17 4 3 7 10

output:

183056086

result:

ok single line: '183056086'

Test #14:

score: 15
Accepted
time: 1ms
memory: 4140kb

input:

14 97
25 2 54 78 9 29 34 99 82 36 14 66 15 64

output:

2

result:

ok single line: '2'

Test #15:

score: 15
Accepted
time: 1ms
memory: 4196kb

input:

14 98
26 70 16 95 30 2 18 96 6 5 52 99 89 24

output:

2

result:

ok single line: '2'

Test #16:

score: 15
Accepted
time: 1ms
memory: 4244kb

input:

14 92
33 3 17 38 39 45 2 48 22 29 9 28 5 10

output:

1235526

result:

ok single line: '1235526'

Test #17:

score: 15
Accepted
time: 1ms
memory: 4056kb

input:

14 29
12 6 16 9 23 20 3 1 8 25 29 26 19 24

output:

2

result:

ok single line: '2'

Test #18:

score: 15
Accepted
time: 1ms
memory: 4256kb

input:

14 43
17 11 7 8 5 2 10 16 12 9 15 3 14 18

output:

110733412

result:

ok single line: '110733412'

Test #19:

score: 15
Accepted
time: 1ms
memory: 4372kb

input:

14 72
7 13 19 16 20 15 4 10 1 6 14 11 5 8

output:

347124497

result:

ok single line: '347124497'

Test #20:

score: 15
Accepted
time: 1ms
memory: 4180kb

input:

14 83
18 73 40 48 86 97 24 21 45 69 36 16 26 35

output:

6

result:

ok single line: '6'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%