답안 #488633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
488633 2021-11-19T20:04:03 Z Savu_Stefan_Catalin Skyscraper (JOI16_skyscraper) C++14
5 / 100
4 ms 4132 KB
#include <iostream>
#include <algorithm>
using namespace std;
long long n,s,i,j,S,F,L,a[1005],dp[105][105][2005][2][2],sum;
int main()
{
    cin>>n>>L;
    for (i=1;i<=n;++i)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    dp[1][0][0][0][0]=1;
    dp[1][0][0][0][1]=1;
    dp[1][0][0][1][0]=1;
    dp[1][0][0][1][1]=1;
    for (i=1;i<n;++i)
    for (j=0;j<=n;++j)
    for (s=0;s<=L;++s)
    for (S=0;S<=1;++S)
    for (F=0;F<=1;++F)
    {
    if (j>0)
    dp[i+1][j-1][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][F]+=dp[i][j][s][S][F]*j;
    dp[i+1][j+0][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][F]+=dp[i][j][s][S][F]*j*2;
    dp[i+1][j+1][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][F]+=dp[i][j][s][S][F]*j;

    if (S==1) dp[i+1][j+1][s+(2*j+S+F)*(a[i+1]-a[i+0])][0][F]+=dp[i][j][s][S][F];
    if (S==1) dp[i+1][j+1][s+(2*j+S+F)*(a[i+1]-a[i+0])][1][F]+=dp[i][j][s][S][F];
    if (S==1) dp[i+1][j][s+(2*j+S+F)*(a[i+1]-a[i+0])][0][F]+=dp[i][j][s][S][F];
    if (S==1) dp[i+1][j][s+(2*j+S+F)*(a[i+1]-a[i+0])][1][F]+=dp[i][j][s][S][F];

    if (F==1) dp[i+1][j+1][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][0]+=dp[i][j][s][S][F];
    if (F==1) dp[i+1][j+1][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][1]+=dp[i][j][s][S][F];
    if (F==1) dp[i+1][j][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][0]+=dp[i][j][s][S][F];
    if (F==1) dp[i+1][j][s+(2*j+S+F)*(a[i+1]-a[i+0])][S][1]+=dp[i][j][s][S][F];
    }
    for (s=0;s<=L;++s)
        sum+=dp[n][0][s][0][0];
    cout<<sum;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 588 KB Output is correct
5 Correct 4 ms 4132 KB Output is correct
6 Correct 3 ms 3788 KB Output is correct
7 Correct 1 ms 1228 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 3 ms 3624 KB Output is correct
10 Correct 1 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1228 KB Output is correct
2 Correct 2 ms 1996 KB Output is correct
3 Correct 1 ms 1484 KB Output is correct
4 Correct 2 ms 2048 KB Output is correct
5 Correct 2 ms 2124 KB Output is correct
6 Correct 2 ms 1868 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Incorrect 1 ms 1740 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 588 KB Output is correct
5 Correct 4 ms 4132 KB Output is correct
6 Correct 3 ms 3788 KB Output is correct
7 Correct 1 ms 1228 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 3 ms 3624 KB Output is correct
10 Correct 1 ms 844 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 2 ms 1996 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 2 ms 2048 KB Output is correct
15 Correct 2 ms 2124 KB Output is correct
16 Correct 2 ms 1868 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 1 ms 1484 KB Output is correct
19 Incorrect 1 ms 1740 KB Output isn't correct
20 Halted 0 ms 0 KB -