Submission #973593

# Submission time Handle Problem Language Result Execution time Memory
973593 2024-05-02T08:08:21 Z Aiperiii Skyscraper (JOI16_skyscraper) C++14
15 / 100
519 ms 203856 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int mod=1e9+7;
int dp[(1<<15)][15][105];
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,L;
    cin>>n>>L;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[(1<<i)][i][0]=1;
    }
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            if((i&(1<<j))){
                for(int l=0;l<n;l++){
                    for(int s=0;s<=L;s++){
                        if(s+abs(a[l]-a[j])<=L){
                            dp[i][j][s+abs(a[l]-a[j])]+=dp[i^(1<<j)][l][s];
                            dp[i][j][s+abs(a[l]-a[j])]%=mod;
                        }
                        
                    }
                }
            }
        }
    }
    int ans=0;
    for(int l=0;l<n;l++){
        for(int s=0;s<=L;s++){
            ans+=dp[(1<<n)-1][l][s];
            ans%=mod;
        }
    }
    cout<<ans<<"\n";
}
/*
4 10
3 6 2 9
 
8 35
3 7 1 5 10 2 11 6
*/


# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 20 ms 4868 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 84 ms 52008 KB Output is correct
2 Correct 488 ms 203644 KB Output is correct
3 Correct 336 ms 203856 KB Output is correct
4 Correct 519 ms 203560 KB Output is correct
5 Correct 464 ms 203444 KB Output is correct
6 Correct 492 ms 203604 KB Output is correct
7 Correct 226 ms 203596 KB Output is correct
8 Correct 311 ms 203600 KB Output is correct
9 Correct 402 ms 203576 KB Output is correct
10 Correct 430 ms 203512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 20 ms 4868 KB Output isn't correct
6 Halted 0 ms 0 KB -