Submission #245913

# Submission time Handle Problem Language Result Execution time Memory
245913 2020-07-07T18:48:00 Z Goolakh Skyscraper (JOI16_skyscraper) C++17
20 / 100
213 ms 287356 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e2+10, maxm=1e3+10, lg=21, mod=1e9+7, inf=1e18;

ll n,L,a[maxn],dp[maxn][maxn][maxm][3];
ll moz(ll i,ll cc,ll sum,ll tend){
	if(sum>L || (cc==0 && i!=1)) return 0;
	if(i==n+1) return tend==2 && cc==1;
	ll &x=dp[i][cc][sum][tend];
	if(x!=-1) return x;
	x=0;
	sum=sum+(a[i]-a[i-1])*(2*cc-tend);
	if(cc>=1) x+=(2*cc-tend)*moz(i+1,cc,sum,tend); // merge1
	if(cc>=2) x+=(cc-1)*moz(i+1,cc-1,sum,tend); // merge2
	x+=(cc+1-tend)*moz(i+1,cc+1,sum,tend); // mostaghel vasat
	if(tend<2){
		x+=(2-tend)*moz(i+1,cc+1,sum,tend+1); // mostaghel end
		x+=(2-tend)*moz(i+1,cc,sum,tend+1); // bechasbe be tah bokone end
	}
	return x%mod;
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>L;
	if(n==1) return cout<<1,0;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	memset(dp,-1,sizeof(dp));
	cout<<moz(1,0,0,0);
 	
	return 0;
}



# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 149 ms 287352 KB Output is correct
3 Correct 149 ms 287352 KB Output is correct
4 Correct 147 ms 287356 KB Output is correct
5 Correct 152 ms 287352 KB Output is correct
6 Correct 147 ms 287352 KB Output is correct
7 Correct 151 ms 287352 KB Output is correct
8 Correct 147 ms 287356 KB Output is correct
9 Correct 149 ms 287352 KB Output is correct
10 Correct 146 ms 287352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 287352 KB Output is correct
2 Correct 152 ms 287324 KB Output is correct
3 Correct 151 ms 287352 KB Output is correct
4 Correct 145 ms 287352 KB Output is correct
5 Correct 146 ms 287352 KB Output is correct
6 Correct 150 ms 287352 KB Output is correct
7 Correct 147 ms 287352 KB Output is correct
8 Correct 150 ms 287352 KB Output is correct
9 Correct 151 ms 287352 KB Output is correct
10 Correct 150 ms 287352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 149 ms 287352 KB Output is correct
3 Correct 149 ms 287352 KB Output is correct
4 Correct 147 ms 287356 KB Output is correct
5 Correct 152 ms 287352 KB Output is correct
6 Correct 147 ms 287352 KB Output is correct
7 Correct 151 ms 287352 KB Output is correct
8 Correct 147 ms 287356 KB Output is correct
9 Correct 149 ms 287352 KB Output is correct
10 Correct 146 ms 287352 KB Output is correct
11 Correct 154 ms 287352 KB Output is correct
12 Correct 152 ms 287324 KB Output is correct
13 Correct 151 ms 287352 KB Output is correct
14 Correct 145 ms 287352 KB Output is correct
15 Correct 146 ms 287352 KB Output is correct
16 Correct 150 ms 287352 KB Output is correct
17 Correct 147 ms 287352 KB Output is correct
18 Correct 150 ms 287352 KB Output is correct
19 Correct 151 ms 287352 KB Output is correct
20 Correct 150 ms 287352 KB Output is correct
21 Correct 144 ms 287352 KB Output is correct
22 Incorrect 213 ms 287352 KB Output isn't correct
23 Halted 0 ms 0 KB -