답안 #291266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291266 2020-09-05T02:40:49 Z YJU Skyscraper (JOI16_skyscraper) C++14
100 / 100
193 ms 81912 KB
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=1e2+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()



void add(ll &A,ll B){
	A=(A+B)%MOD;
	return;
}

ll n,k,u[N],dp[N][N][1005][3],ans;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>k;
	REP1(i,n)cin>>u[i];
	sort(u+1,u+n+1);
	dp[1][1][0][0]=dp[1][1][0][2]=1;
	dp[1][1][0][1]=2;
	REP1(i,n-1){
		REP1(j,i){
			REP(cost,k+1){
				REP(ty,3){
					ll price=cost+(u[i+1]-u[i])*(2*j-ty);
					if(price>k)continue;
					add(dp[i+1][j][price][ty],dp[i][j][cost][ty]*(2*j-ty)%MOD);
					add(dp[i+1][j+1][price][ty],dp[i][j][cost][ty]*(j-ty+1)%MOD);
					add(dp[i+1][j-1][price][ty],dp[i][j][cost][ty]*(j-1)%MOD);
					if(ty<2){
						add(dp[i+1][j][price][ty+1],dp[i][j][cost][ty]*(2-ty)%MOD);
						add(dp[i+1][j+1][price][ty+1],dp[i][j][cost][ty]*(2-ty)%MOD);
					}
				}
			}
		}
	}
	REP(i,k+1)add(ans,dp[n][1][i][2]);
	cout<<ans<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 1152 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 2 ms 1152 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 896 KB Output is correct
2 Correct 1 ms 896 KB Output is correct
3 Correct 1 ms 1024 KB Output is correct
4 Correct 1 ms 896 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 1024 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 2 ms 1024 KB Output is correct
9 Correct 1 ms 1024 KB Output is correct
10 Correct 1 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 1152 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 2 ms 1152 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 1 ms 896 KB Output is correct
12 Correct 1 ms 896 KB Output is correct
13 Correct 1 ms 1024 KB Output is correct
14 Correct 1 ms 896 KB Output is correct
15 Correct 1 ms 1024 KB Output is correct
16 Correct 1 ms 1024 KB Output is correct
17 Correct 1 ms 896 KB Output is correct
18 Correct 2 ms 1024 KB Output is correct
19 Correct 1 ms 1024 KB Output is correct
20 Correct 1 ms 896 KB Output is correct
21 Correct 4 ms 3584 KB Output is correct
22 Correct 159 ms 69076 KB Output is correct
23 Correct 189 ms 81272 KB Output is correct
24 Correct 173 ms 78968 KB Output is correct
25 Correct 193 ms 81912 KB Output is correct
26 Correct 168 ms 76408 KB Output is correct
27 Correct 73 ms 43256 KB Output is correct
28 Correct 92 ms 50044 KB Output is correct
29 Correct 160 ms 76152 KB Output is correct
30 Correct 190 ms 81912 KB Output is correct