Submission #287890

# Submission time Handle Problem Language Result Execution time Memory
287890 2020-09-01T06:04:22 Z 임성재(#5782) Skyscraper (JOI16_skyscraper) C++17
0 / 100
432 ms 107192 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int n, l;
int a[1010];
int dp[17000][15][111];

int main() {
	fast;

	cin >> n >> l;

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

	for(int i=1; i<(1<<n); i++) {
		if(__builtin_popcount(i) == 1) {
			for(int j=0; j<n; j++) {
				if(i == (1<<j)) {
					dp[i][j][0] = 1;
				}
			}
			continue;
		}

		for(int j=0; j<n; j++) {
			if(~i & (1<<j)) continue;

			for(int k=0; k<=l; k++) {
				for(int m=0; m<n; m++) {
					if(m == j) continue;
					if(~i & (1<<m)) continue;
					if(abs(a[m] - a[j]) > k) continue;
					
					dp[i][j][k] += dp[i ^ (1<<j)][m][k - abs(a[m] - a[j])];
				}
			}
		}
	}

	ll ans = 0;
	for(int i=0; i<n; i++) {
		for(int j=0; j<=l; j++) {
			ans += dp[(1<<n)-1][i][j];
		}
	}

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 640 KB Output is correct
5 Incorrect 15 ms 1920 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 26876 KB Output is correct
2 Correct 424 ms 106984 KB Output is correct
3 Correct 262 ms 106920 KB Output is correct
4 Correct 419 ms 107192 KB Output is correct
5 Correct 432 ms 106944 KB Output is correct
6 Correct 412 ms 106976 KB Output is correct
7 Correct 231 ms 106880 KB Output is correct
8 Correct 246 ms 106872 KB Output is correct
9 Incorrect 327 ms 106936 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 640 KB Output is correct
5 Incorrect 15 ms 1920 KB Output isn't correct
6 Halted 0 ms 0 KB -