# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
866789 | 2023-10-27T04:40:54 Z | prohacker | Skyscraper (JOI16_skyscraper) | C++14 | 1 ms | 860 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define int long long using namespace std; const int N = 105; const int INF = INT_MAX; const int mod = 1e9+7; int n,lim,dp[N][N][1010][3],a[N]; int ans; void add(int &x, const int y) { x += y; if(x >= mod) { x -= mod; } } signed main() { if (fopen(" Skyscraper.inp", "r")) { freopen(" Skyscraper.inp", "r", stdin); freopen(" Skyscraper.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> lim; for(int i = 1 ; i <= n ; i++) { cin >> a[i]; } sort(a+1,a+n+1); a[n+1] = 100010; dp[0][0][0][0] = 1; for(int i = 1 ; i <= n ; i++) { for(int j = 1 ; j <= i ; j++) { for(int k = 0 ; k <= lim ; k++) { for(int m = 0 ; m <= 2 ; m++) { int delta = (2*j-m)*(a[i+1]-a[i]); if(delta > k) { continue; } add(dp[i][j][k][m],dp[i-1][j-1][k-delta][m]); add(dp[i][j][k][m],1LL*(2*j-m)*dp[i-1][j][k-delta][m]%mod); if(m > 0) { if(j > 0) { add(dp[i][j][k][m],1LL*(3-m)*dp[i-1][j-1][k-delta][m-1]%mod); } if(m == 1) { add(dp[i][j][k][m],1LL*2*j*dp[i-1][j][k-delta][m-1]%mod); } else { if(i == n) { add(dp[i][j][k][m],dp[i-1][j][k-delta][m-1]); } else { if(j > 0) { add(dp[i][j][k][m],1LL*(j-1)*dp[i-1][j][k-delta][m-1]%mod); } } } } if(m == 2) { if(i == n) { add(dp[i][j][k][m],dp[i-1][j+1][k-delta][m]); } else { add(dp[i][j][k][m],1LL*j*(j-1)*dp[i-1][j+1][k-delta][m]%mod); } } else if(m == 1) { add(dp[i][j][k][m],1LL*j*j*dp[i-1][j+1][k-delta][m]%mod); } else { add(dp[i][j][k][m],1LL*j*(j+1)*dp[i-1][j+1][k-delta][m]%mod); } } } } } for(int i = 0 ; i <= lim ; i++) { add(ans,dp[n][1][i][2]); } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 860 KB | Output is correct |
2 | Correct | 1 ms | 860 KB | Output is correct |
3 | Correct | 1 ms | 860 KB | Output is correct |
4 | Correct | 1 ms | 860 KB | Output is correct |
5 | Correct | 1 ms | 860 KB | Output is correct |
6 | Correct | 1 ms | 860 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 860 KB | Output is correct |
9 | Correct | 1 ms | 860 KB | Output is correct |
10 | Correct | 1 ms | 860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |