Submission #1085854

# Submission time Handle Problem Language Result Execution time Memory
1085854 2024-09-08T22:12:59 Z Raiden Skyscraper (JOI16_skyscraper) C++14
15 / 100
73 ms 136528 KB
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 105;
int dp[3][MAX][MAX][MAX * 10], n;
int arr[MAX];
int f(int alive_ends, int i,int components, int sm){
	if(alive_ends < 0) return 0;
	if(sm < 0) return 0;
	if(i == n) return alive_ends == 0 && components == 1;
	int &ret = dp[alive_ends][i][components][sm];
	if(~ret) return ret;
	ret = 0;
	sm -= (2 * components - 2 + alive_ends) * (arr[i] - arr[i - 1]);
	ret = (ret + 1LL * (2 * components - 2 + alive_ends) * f(alive_ends, i + 1, components, sm)) % MOD;
	ret = (ret + 1LL * alive_ends * f(alive_ends - 1, i + 1, components, sm)) % MOD;
	ret = (ret + 1LL * (components - 1 + alive_ends) * f(alive_ends, i + 1, components + 1, sm)) % MOD;
	ret = (ret + 1LL * alive_ends * f(alive_ends - 1, i + 1, components + 1, sm)) % MOD;
	ret = (ret + 1LL * (components - 1) * f(alive_ends, i + 1, components - 1, sm)) % MOD;
	return ret;
}
void solve(){
	int k;
	cin >> n >> k;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < n; i++) cin >> arr[i];
	sort(arr, arr + n);
	cout << (f(2, 1, 1, k) + 2LL * f(1, 1, 1, k)) % MOD << '\n';

}

int32_t main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int t = 1;
	// cin >> t;
	while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 136336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 136296 KB Output is correct
2 Correct 69 ms 136280 KB Output is correct
3 Correct 68 ms 136152 KB Output is correct
4 Correct 71 ms 136272 KB Output is correct
5 Correct 66 ms 136256 KB Output is correct
6 Correct 68 ms 136528 KB Output is correct
7 Correct 66 ms 136272 KB Output is correct
8 Correct 64 ms 136220 KB Output is correct
9 Correct 66 ms 136272 KB Output is correct
10 Correct 65 ms 136272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 136336 KB Output isn't correct
2 Halted 0 ms 0 KB -