답안 #799630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799630 2023-07-31T17:01:59 Z manizare Skyscraper (JOI16_skyscraper) C++14
100 / 100
284 ms 234560 KB
#include <bits/stdc++.h>  
#define pii pair <int,int>  
#define F first  
#define S second  
#define all(a) a.begin(),a.end()  
#define pb push_back 
#define int long long 
using namespace std ;

const int maxn = 102 , inf  = 1e18 , mod = 1e9 + 7 ;  
int dp[3][102][102][1002] , a[102] ; 
signed main(){ 
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) ;
  int n , l ;cin >> n >> l ;
  for(int i = 1 ; i <= n; i++){
    cin >> a[i] ; 
  }
  if (n == 1) return cout << 1, 0;
  sort(a+1 , a+1+n) ; 
  dp[0][1][1][0] = 1 ; 
  dp[1][1][1][0] = 2; 
  for(int z =0 ;  z< 3 ; z++){
    for(int i = 2; i <= n; i ++){
      int d = a[i] - a[i-1] ; 
      for(int j = 1 ; j <= n ; j++){
        for(int k = 0 ; k <= l ; k++){
          if(k-(2*(j+1)-z)*d >= 0)dp[z][i][j][k] += (dp[z][i-1][j+1][k-(2*(j+1)-z)*d] * j %mod) ;    
          if(k-d*(2*j - z) >= 0 )dp[z][i][j][k] += (dp[z][i-1][j][k-d*(2*j - z)] *(2*j-z) % mod) ;
          if(k-(2*(j-1)-z)*d >= 0)dp[z][i][j][k] += (dp[z][i-1][j-1][k-(2*(j-1)-z)*d] *(j - z) %mod) ;
          if(z!=0){
            if(k-(2*j-(z-1))*d >= 0 ) dp[z][i][j][k] += (dp[z-1][i-1][j][k-(2*j-(z-1))*d] * (3-z) % mod) ; 
            if(k-d*(2*j-2-(z-1)) >= 0)dp[z][i][j][k] += (dp[z-1][i-1][j-1][k-d*(2*j-2-(z-1))] * (3-z) % mod) ;
          }
          dp[z][i][j][k] %= mod ;
        }
      }
    }
  }
  int ans =0 ; 
  for(int i =0 ; i <= l ; i++){
    ans = (ans + dp[2][n][1][i])%mod ;
  }
  cout << ans ; 
} 
/* 
 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 2 ms 1748 KB Output is correct
6 Correct 2 ms 1748 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 2 ms 1748 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2132 KB Output is correct
2 Correct 2 ms 2900 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2900 KB Output is correct
5 Correct 2 ms 2900 KB Output is correct
6 Correct 2 ms 2932 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2772 KB Output is correct
10 Correct 2 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 2 ms 1748 KB Output is correct
6 Correct 2 ms 1748 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 2 ms 1748 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 2132 KB Output is correct
12 Correct 2 ms 2900 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2900 KB Output is correct
15 Correct 2 ms 2900 KB Output is correct
16 Correct 2 ms 2932 KB Output is correct
17 Correct 3 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2900 KB Output is correct
21 Correct 12 ms 20596 KB Output is correct
22 Correct 222 ms 142232 KB Output is correct
23 Correct 278 ms 234368 KB Output is correct
24 Correct 229 ms 233808 KB Output is correct
25 Correct 284 ms 234560 KB Output is correct
26 Correct 238 ms 234044 KB Output is correct
27 Correct 133 ms 176132 KB Output is correct
28 Correct 158 ms 189132 KB Output is correct
29 Correct 232 ms 233428 KB Output is correct
30 Correct 254 ms 234396 KB Output is correct