# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523416 | 2022-02-07T15:40:39 Z | denniskim | Skyscraper (JOI16_skyscraper) | C++17 | 417 ms | 79812 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define MAX 9223372036854775807LL #define MIN -9223372036854775807LL #define INF 0x3f3f3f3f3f3f3f3f #define fi first #define se second ll n, L; ll a[110]; ll dp[110][110][1010][3]; ll ss = 1000000007; int main(void) { scanf("%lld %lld", &n, &L); for(ll i = 1 ; i <= n ; i++) scanf("%lld", &a[i]); sort(a + 1, a + 1 + n); dp[1][1][0][0] = 1; dp[1][1][0][1] = 2; dp[1][1][0][2] = 1; for(ll i = 2 ; i <= n ; i++) { for(ll j = 1 ; j <= i ; j++) { for(ll k = 0 ; k <= L ; k++) { for(ll l = 0 ; l <= 2 ; l++) { if(k - ((j - 1) * 2 - l) * (a[i] - a[i - 1]) >= 0 && (j - l) >= 0) dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][j - 1][k - ((j - 1) * 2 - l) * (a[i] - a[i - 1])][l] * (j - l) % ss) % ss; if(k - ((j - 1) * 2 - (l - 1)) * (a[i] - a[i - 1]) >= 0 && (l - 1) >= 0) dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][j - 1][k - ((j - 1) * 2 - (l - 1)) * (a[i] - a[i - 1])][l - 1] * (3 - l) % ss) % ss; if(k - (j * 2 - l) * (a[i] - a[i - 1]) >= 0) dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][j][k - (j * 2 - l) * (a[i] - a[i - 1])][l] * (2 * j - l) % ss) % ss; if(k - (j * 2 - (l - 1)) * (a[i] - a[i - 1]) >= 0 && (l - 1) >= 0) dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][j][k - (j * 2 - (l - 1)) * (a[i] - a[i - 1])][l - 1] * (3 - l) % ss) % ss; if(k - ((j + 1) * 2 - l) * (a[i] - a[i - 1]) >= 0) dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][j + 1][k - ((j + 1) * 2 - l) * (a[i] - a[i - 1])][l] * j % ss) % ss; } } } } ll ans = 0; for(ll i = 0 ; i <= L ; i++) ans = (ans + dp[n][1][i][2]) % ss; printf("%lld", ans % ss < 0 ? ans % ss + ss : ans % ss); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 292 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 2 ms | 844 KB | Output is correct |
6 | Correct | 2 ms | 716 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 3 ms | 972 KB | Output is correct |
10 | Correct | 1 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 716 KB | Output is correct |
2 | Correct | 1 ms | 844 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 2 ms | 816 KB | Output is correct |
5 | Correct | 2 ms | 844 KB | Output is correct |
6 | Correct | 2 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 800 KB | Output is correct |
9 | Correct | 2 ms | 972 KB | Output is correct |
10 | Correct | 1 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 292 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 2 ms | 844 KB | Output is correct |
6 | Correct | 2 ms | 716 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 3 ms | 972 KB | Output is correct |
10 | Correct | 1 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 716 KB | Output is correct |
12 | Correct | 1 ms | 844 KB | Output is correct |
13 | Correct | 1 ms | 844 KB | Output is correct |
14 | Correct | 2 ms | 816 KB | Output is correct |
15 | Correct | 2 ms | 844 KB | Output is correct |
16 | Correct | 2 ms | 972 KB | Output is correct |
17 | Correct | 1 ms | 716 KB | Output is correct |
18 | Correct | 1 ms | 800 KB | Output is correct |
19 | Correct | 2 ms | 972 KB | Output is correct |
20 | Correct | 1 ms | 844 KB | Output is correct |
21 | Correct | 4 ms | 3276 KB | Output is correct |
22 | Correct | 325 ms | 67304 KB | Output is correct |
23 | Correct | 417 ms | 79020 KB | Output is correct |
24 | Correct | 362 ms | 76868 KB | Output is correct |
25 | Correct | 394 ms | 79604 KB | Output is correct |
26 | Correct | 349 ms | 74228 KB | Output is correct |
27 | Correct | 138 ms | 42368 KB | Output is correct |
28 | Correct | 174 ms | 48892 KB | Output is correct |
29 | Correct | 341 ms | 74420 KB | Output is correct |
30 | Correct | 402 ms | 79812 KB | Output is correct |