답안 #941400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941400 2024-03-08T17:49:29 Z Hacv16 Skyscraper (JOI16_skyscraper) C++17
15 / 100
434 ms 91080 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 14;
const int MAXL = 101;
const int MOD = 1e9 + 7;

int n, l, a[MAXN];
int dp[1 << MAXN][MAXN][MAXL];

int32_t main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> l;

    for(int i = 0; i < n; i++)
        cin >> a[i];

    for(int i = 0; i < n; i++)
        dp[(1 << i)][i][0] = 1;

    for(int mask = 1; mask < (1 << n); mask++)
    {
        for(int last = 0; last < n; last++)
        {
            if((mask & (1 << last)) == 0) continue;

            for(int pen = 0; pen <= l; pen++)
            {
                for(int prev = 0; prev < n; prev++)
                {
                    if((mask & (1 << prev)) == 0 || prev == last) continue;

                    int curPen = abs(a[last] - a[prev]);

                    if(curPen <= pen)
                        dp[mask][last][pen] = (dp[mask][last][pen] + dp[mask ^ (1 << last)][prev][pen - curPen]) % MOD;
                }
            }
        }
    }

    int ans = 0;

    for(int i = 0; i < n; i++)
        for(int j = 0; j <= l; j++)
            ans = (ans + dp[(1 << n) - 1][i][j]) % MOD;

    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 656 KB Output is correct
5 Incorrect 15 ms 2904 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 23032 KB Output is correct
2 Correct 427 ms 90964 KB Output is correct
3 Correct 232 ms 90960 KB Output is correct
4 Correct 429 ms 91052 KB Output is correct
5 Correct 434 ms 91080 KB Output is correct
6 Correct 429 ms 91072 KB Output is correct
7 Correct 204 ms 90964 KB Output is correct
8 Correct 231 ms 90912 KB Output is correct
9 Correct 321 ms 90940 KB Output is correct
10 Correct 381 ms 90964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 656 KB Output is correct
5 Incorrect 15 ms 2904 KB Output isn't correct
6 Halted 0 ms 0 KB -