Submission #147556

# Submission time Handle Problem Language Result Execution time Memory
147556 2019-08-30T04:16:00 Z Gandook Skyscraper (JOI16_skyscraper) C++17
15 / 100
3 ms 760 KB
#include <bits/stdc++.h>

#define SZ(x) (((int)x.size()))

typedef long long ll;

using namespace std;

const int mod = 1000000007, maxn = 110, maxm = 55, maxl = 1*1000+10;
int dp[maxn][maxm][maxl][3], n, l, a[maxn], cost;

int main()
{
	cin >> n >> l;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i <= l; i++)
		dp[0][0][i][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= min(i, (n + 1) / 2); j++)
		{
			for (int k = 0; k <= l; k++)
			{
				for (int m = 0; m < 3; m++)
				{
					cost = (j * 2 - m) * (a[i] - a[i - 1]);
					if (cost > k)
						continue;
					if (m > 0)
					{
						dp[i][j][k][m] += (dp[i - 1][j][k - cost][m - 1] * (3 - m)) % mod;
						dp[i][j][k][m] %= mod;
						if (i + j + 1 - m <= n)
						{
							dp[i][j][k][m] += (dp[i - 1][j - 1][k - cost][m - 1] * (3 - m)) % mod;
							dp[i][j][k][m] %= mod;
						}
					}
					if (i + j + 1 - m <= n)
					{
						dp[i][j][k][m] += ((ll)dp[i - 1][j - 1][k - cost][m] * (j - m)) % mod;
						dp[i][j][k][m] %= mod;
						dp[i][j][k][m] += ((ll)dp[i - 1][j][k - cost][m] * (j * 2 - m)) % mod;
						dp[i][j][k][m] %= mod;
					}
					if (j < (n + 1) / 2)
					{
						dp[i][j][k][m] += ((ll)dp[i - 1][j + 1][k - cost][m] * j) % mod;
						dp[i][j][k][m] %= mod;
					}
					//cerr << i << " " << j << " " << k << " " << m << " " << dp[i][j][k][m] << endl;
				}
			}
		}
	}
	cout << dp[n][1][l][2];
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -