# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287896 |
2020-09-01T06:09:51 Z |
임성재(#5782) |
Skyscraper (JOI16_skyscraper) |
C++17 |
|
702 ms |
206192 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;
const ll Mod = 1e9 + 7;
int n, l;
int a[1010];
ll 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])];
dp[i][j][k] %= Mod;
}
}
}
}
ll ans = 0;
for(int i=0; i<n; i++) {
for(int j=0; j<=l; j++) {
ans += dp[(1<<n)-1][i][j];
ans %= Mod;
}
}
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 |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Incorrect |
25 ms |
3456 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
49020 KB |
Output is correct |
2 |
Correct |
698 ms |
206072 KB |
Output is correct |
3 |
Correct |
457 ms |
204792 KB |
Output is correct |
4 |
Correct |
702 ms |
206192 KB |
Output is correct |
5 |
Correct |
683 ms |
206072 KB |
Output is correct |
6 |
Correct |
696 ms |
206128 KB |
Output is correct |
7 |
Correct |
355 ms |
203896 KB |
Output is correct |
8 |
Correct |
435 ms |
204920 KB |
Output is correct |
9 |
Correct |
609 ms |
205432 KB |
Output is correct |
10 |
Correct |
636 ms |
205560 KB |
Output is correct |
# |
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 |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Incorrect |
25 ms |
3456 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |