# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
839049 | 2023-08-28T14:37:50 Z | guagua0407 | Skyscraper (JOI16_skyscraper) | C++17 | 126 ms | 81920 KB |
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=105; const int mxl=1005; const int mod=1e9+7; ll dp[mxn][mxn][mxl][3]; int a[mxn]; int main() {_ int n,L; cin>>n>>L; for(int i=1;i<=n;i++){ cin>>a[i]; } if(n==1){ cout<<1<<'\n'; return 0; } sort(a+1,a+n+1); dp[1][1][0][0]=1; dp[1][1][0][1]=2; ll ans=0; for(int i=1;i<n;i++){ int diff=a[i+1]-a[i]; for(int j=1;j<=i;j++){ for(int k=0;k<=L;k++){ // new for(int m=0;m<3;m++){ if(k+diff*(2*j-m)>L) continue; dp[i+1][j+1][k+diff*(2*j-m)][m]=(dp[i+1][j+1][k+diff*(2*j-m)][m]+dp[i][j][k][m])%mod; if(m<2) dp[i+1][j+1][k+diff*(2*j-m)][m+1]=(dp[i+1][j+1][k+diff*(2*j-m)][m+1]+dp[i][j][k][m]*(1+(m==0)))%mod; } // continue for(int m=0;m<3;m++){ if(k+diff*(2*j-m)>L) continue; dp[i+1][j][k+diff*(2*j-m)][m]=(dp[i+1][j][k+diff*(2*j-m)][m]+dp[i][j][k][m]*(2*j-m))%mod; } if(k+diff*(2*j-0)<=L) dp[i+1][j][k+diff*(2*j-0)][1]=(dp[i+1][j][k+diff*(2*j-0)][1]+dp[i][j][k][0]*(2*j))%mod; if(k+diff*(2*j-1)<=L) dp[i+1][j][k+diff*(2*j-1)][2]=(dp[i+1][j][k+diff*(2*j-1)][2]+dp[i][j][k][1]*(j-1+(i==n-1 and j==1)))%mod; // combine for(int m=0;m<3;m++){ if(k+diff*(2*j-m)>L) continue; dp[i+1][j-1][k+diff*(2*j-m)][m]=(dp[i+1][j-1][k+diff*(2*j-m)][m]+dp[i][j][k][m]*(j*(j-1)-(j-1)*m+(i==n-1 and m==2)))%mod; } } } } for(int i=0;i<=L;i++){ ans=(ans+dp[n][1][i][2])%mod; } cout<<ans<<'\n'; return 0; } //maybe its multiset not set
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 1108 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 1108 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 852 KB | Output is correct |
2 | Correct | 1 ms | 852 KB | Output is correct |
3 | Correct | 1 ms | 852 KB | Output is correct |
4 | Correct | 1 ms | 852 KB | Output is correct |
5 | Correct | 1 ms | 852 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 852 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 852 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 1108 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 1108 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 852 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 852 KB | Output is correct |
15 | Correct | 1 ms | 852 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
18 | Correct | 1 ms | 852 KB | Output is correct |
19 | Correct | 1 ms | 980 KB | Output is correct |
20 | Correct | 1 ms | 852 KB | Output is correct |
21 | Correct | 3 ms | 3540 KB | Output is correct |
22 | Correct | 94 ms | 69144 KB | Output is correct |
23 | Correct | 122 ms | 81100 KB | Output is correct |
24 | Correct | 109 ms | 79056 KB | Output is correct |
25 | Correct | 126 ms | 81736 KB | Output is correct |
26 | Correct | 112 ms | 76564 KB | Output is correct |
27 | Correct | 50 ms | 43212 KB | Output is correct |
28 | Correct | 68 ms | 49900 KB | Output is correct |
29 | Correct | 109 ms | 76248 KB | Output is correct |
30 | Correct | 126 ms | 81920 KB | Output is correct |