답안 #1116758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116758 2024-11-22T10:43:58 Z Tai_xiu Skyscraper (JOI16_skyscraper) C++14
100 / 100
50 ms 3124 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define i128 int128
#define ii pair<int,int>
#define ld long double
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pair<int,int>>
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FOR1(i,a,b,c) for (int i=a;i<=b;i+=c)
#define REP(i,a,b) for (int i=a;i>=b;i--)
#define REP1(i,a,b,c) for(int i=b;i>=a;i-=c)
#define endh '\n';
#define len(a) a.length()
#define pb(c) push_back(c)
#define elif else if
#define ppb() pop_back()
#define rong std::npos
#define all(c) (c.begin(),c.end())
#define Z int
#define R double
#define lcm(a,b) ((int) (a/__gcd(a,b))*b)
#define mk(a,b) make_pair(a,b)
Z dx4[]={-1,1,0,0};
Z dy4[]={0,0,1,-1};
string co="YES",khong="NO";
const int mod=1e9+7;
Z dp[2][103][1003][4];
Z a[103];
Z n,L;
Z add (Z a,Z b)
{
    a%=mod;
    b%=mod;
    a+=b;
    return a%mod;
}
/*
1 1
1
*/
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    dp[1][1][0][0]=1;
    dp[1][1][0][1]=2;
    cin>>n>>L;
    FOR(i,1,n) cin>>a[i];
     if (n == 1) return cout << 1 << '\n', 0;
    sort(a+1,a+n+1);
    FOR(i,2,n){
        Z curr=(i&1);
        Z prev=(curr^1);
        FOR(cc,1,n){
            FOR(sum,0,L){
                FOR(bien,0,2){
                    Z val=dp[prev][cc][sum][bien];
                    Z newsum=(2*cc-bien)*(a[i]-a[i-1])+sum;
                    if (val==0) continue;
                    if (newsum<=L) {
                        // them 1 tplt
                        {


                        dp[curr][cc+1][newsum][bien]= add(dp[curr][cc+1][newsum][bien],(cc+1-bien)*val);
                        dp[curr][cc+1][newsum][bien+1]=add(dp[curr][cc+1][newsum][bien+1],(2-bien)*val);
                        }
                        // them vao 1 tplt
                        {

                        dp[curr][cc][newsum][bien]=add(dp[curr][cc][newsum][bien],(2*cc-bien)*val);
                        dp[curr][cc][newsum][bien+1]=add(dp[curr][cc][newsum][bien+1],(2-bien)*val);
                        }
                        // gop
                        {

                        dp[curr][cc-1][newsum][bien]=add(dp[curr][cc-1][newsum][bien],(cc-1)*val);
                        }
                    }
                    dp[prev][cc][sum][bien]=0;
                }
            }
        }

    }
    Z ans=0;
    FOR(i,0,L) ans=add(ans,dp[n&1][1][i][2]);
    cout<<ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2552 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2552 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 50 ms 3124 KB Output is correct
23 Correct 38 ms 2640 KB Output is correct
24 Correct 33 ms 2640 KB Output is correct
25 Correct 40 ms 2640 KB Output is correct
26 Correct 33 ms 2640 KB Output is correct
27 Correct 14 ms 2640 KB Output is correct
28 Correct 19 ms 2640 KB Output is correct
29 Correct 33 ms 2640 KB Output is correct
30 Correct 39 ms 2640 KB Output is correct