답안 #492245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
492245 2021-12-06T07:30:01 Z inluminas Skyscraper (JOI16_skyscraper) C++14
20 / 100
321 ms 233432 KB
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false)
#define inf LLONG_MAX

const ll mod=1e9+7;
ll dp[101][101][1001][3];

int main(){
  fastio;

  int n,L;
  cin>>n>>L;
  int a[n+1];
  for(int i=1;i<=n;i++) cin>>a[i];
  sort(a+1,a+n+1);

  for(int open=0;open<=2;open++){
    dp[1][1][0][open]=1+(open==1);
  }

  for(int i=1;i<n;i++){
    int d=a[i+1]-a[i];
    for(int j=1;j<=n;j++){
      for(int cost=0;cost<=L;cost++){
        for(int close=0;close<=2;close++){
          int nxt=cost+(j+j-close)*d;
          if(nxt<=L){
            dp[i+1][j+1][nxt][close]+=dp[i][j][cost][close]*(j+1-close);
            dp[i+1][j+1][nxt][close]%=mod;


            dp[i+1][j][nxt][close]+=dp[i][j][cost][close]*(j+j-close);
            dp[i+1][j][nxt][close]%=mod;
          }

          if(nxt<=L && j-1>0){
            dp[i+1][j-1][nxt][close]+=dp[i][j][cost][close]*(j-1);
            dp[i+1][j-1][nxt][close]%=mod;
          }

          if(nxt<=L && close+1<=2){
            dp[i+1][j][nxt][close+1]+=dp[i][j][cost][close]*(2-close);
            dp[i+1][j][nxt][close+1]%=mod;

            dp[i+1][j+1][nxt][close+1]+=dp[i][j][cost][close]*(2-close);
            dp[i+1][j+1][nxt][close+1]%=mod;
          }
        }
      }
    }
  }
  ll ans=0;
  for(int cost=0;cost<=L;cost++){
    ans+=dp[n][1][cost][2];
    ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1212 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 1 ms 844 KB Output is correct
8 Correct 1 ms 1228 KB Output is correct
9 Correct 2 ms 1356 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1212 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 2 ms 1228 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 1 ms 1228 KB Output is correct
19 Correct 2 ms 1356 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 3 ms 4172 KB Output is correct
22 Correct 169 ms 128052 KB Output is correct
23 Correct 181 ms 120724 KB Output is correct
24 Correct 178 ms 123968 KB Output is correct
25 Correct 180 ms 124356 KB Output is correct
26 Runtime error 321 ms 233432 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -