답안 #963097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963097 2024-04-14T14:00:11 Z study Skyscraper (JOI16_skyscraper) C++17
15 / 100
1777 ms 394320 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1<<14, inf = LLONG_MAX/2, mod = 1e9+7;

int dp[15][101][N];
vector<int> a;

int32_t main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n,L;
        cin >> n >> L;
        a = vector<int>(n+1);
        for (int i=1; i<=n; ++i){
                cin >> a[i];
        }
        fill_n(&dp[0][0][0],15*N*101,0);
        dp[0][0][0] = 1;
        for (int mask=0; mask<(1<<n); ++mask){
                for (int sum=0; sum<=L; ++sum){
                        for (int last=0; last<=n; ++last){
                                if (last != 0 and !(mask&(1<<(last-1)))) continue;
                                for (int unused=1; unused<=n; ++unused){
                                        if (unused == last or !(mask&(1<<(unused-1)))) continue;
                                        int sum2 = sum;
                                        if (last != 0) sum2 += abs(a[unused]-a[last]);
                                        if (sum2 <= L){
                                                dp[unused][sum2][mask] += dp[last][sum][mask-(1<<(unused-1))];
                                                dp[unused][sum2][mask] %= mod;
                                        }
                                }
                        }
                }
        }
        int ans = 0;
        for (int k=0; k<=n; ++k){
                for (int j=0; j<=L; ++j){
                        ans += dp[k][j][(1<<n)-1];
                        ans %= mod;
                }
        }
        cout << ans;
        return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 194484 KB Output is correct
2 Correct 27 ms 194492 KB Output is correct
3 Correct 24 ms 194648 KB Output is correct
4 Correct 26 ms 194616 KB Output is correct
5 Runtime error 217 ms 394320 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 194648 KB Output is correct
2 Correct 1648 ms 194724 KB Output is correct
3 Correct 564 ms 194728 KB Output is correct
4 Correct 1729 ms 194732 KB Output is correct
5 Correct 1482 ms 194732 KB Output is correct
6 Correct 1777 ms 194728 KB Output is correct
7 Correct 343 ms 194640 KB Output is correct
8 Correct 660 ms 194724 KB Output is correct
9 Correct 1222 ms 194732 KB Output is correct
10 Correct 1384 ms 194732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 194484 KB Output is correct
2 Correct 27 ms 194492 KB Output is correct
3 Correct 24 ms 194648 KB Output is correct
4 Correct 26 ms 194616 KB Output is correct
5 Runtime error 217 ms 394320 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -