# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
839046 | 2023-08-28T14:35:37 Z | guagua0407 | Skyscraper (JOI16_skyscraper) | C++17 | 2 ms | 1492 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++){ 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++){ 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; } 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; 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++){ 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 468 KB | Output is correct |
5 | Incorrect | 2 ms | 1492 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 852 KB | Output is correct |
2 | Correct | 2 ms | 1108 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 1108 KB | Output is correct |
5 | Correct | 1 ms | 1108 KB | Output is correct |
6 | Correct | 1 ms | 1108 KB | Output is correct |
7 | Correct | 1 ms | 852 KB | Output is correct |
8 | Correct | 1 ms | 980 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 1108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 468 KB | Output is correct |
5 | Incorrect | 2 ms | 1492 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |