# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
287891 | 2020-09-01T06:04:41 Z | 송준혁(#5774) | Skyscraper (JOI16_skyscraper) | C++17 | 67 ms | 36984 KB |
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, M; int A[110]; LL D[3][110][110][1010], ans; int main(){ scanf("%d %d", &N, &M); for (int i=1; i<=N; i++) scanf("%d", &A[i]); sort(A+1, A+N+1); D[0][1][1][0]=D[2][1][1][0]=1; D[1][1][1][0]=2; for (int i=1; i<N; i++){ for (int j=1; j<=i; j++){ for (int k=0; k<=M; k++){ for (int t=0; t<=2; t++){ int p = k+(A[i+1]-A[i])*(2*j-t); if (p > M || !D[t][i][j][k]) continue; D[t][i+1][j+1][p] += D[t][i][j][k]*(j-t+1); D[t][i+1][j+1][p] %= MOD; D[t][i+1][j][p] += D[t][i][j][k]*(2*j-t); D[t][i+1][j][p] %= MOD; D[t][i+1][j-1][p] += D[t][i][j][k]*(j-1); D[t][i+1][j-1][p] %= MOD; if (t<2){ D[t+1][i+1][j][p] += D[t][i][j][k]*(2-t); D[t+1][i+1][j][p] %= MOD; D[t+1][i+1][j+1][p] += D[t][i][j][k]*(2-t); D[t+1][i+1][j+1][p] %= MOD; } } } } } for (int i=0; i<=M; i++) ans+=D[2][N][1][i]; printf("%lld\n", ans%MOD); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 640 KB | Output is correct |
5 | Correct | 1 ms | 640 KB | Output is correct |
6 | Correct | 1 ms | 768 KB | Output is correct |
7 | Correct | 1 ms | 640 KB | Output is correct |
8 | Correct | 1 ms | 896 KB | Output is correct |
9 | Correct | 1 ms | 768 KB | Output is correct |
10 | Correct | 1 ms | 896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1408 KB | Output is correct |
2 | Correct | 1 ms | 1152 KB | Output is correct |
3 | Correct | 1 ms | 1408 KB | Output is correct |
4 | Correct | 1 ms | 1152 KB | Output is correct |
5 | Correct | 1 ms | 1152 KB | Output is correct |
6 | Correct | 1 ms | 1408 KB | Output is correct |
7 | Correct | 1 ms | 1024 KB | Output is correct |
8 | Correct | 1 ms | 1536 KB | Output is correct |
9 | Correct | 2 ms | 1664 KB | Output is correct |
10 | Correct | 1 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 640 KB | Output is correct |
5 | Correct | 1 ms | 640 KB | Output is correct |
6 | Correct | 1 ms | 768 KB | Output is correct |
7 | Correct | 1 ms | 640 KB | Output is correct |
8 | Correct | 1 ms | 896 KB | Output is correct |
9 | Correct | 1 ms | 768 KB | Output is correct |
10 | Correct | 1 ms | 896 KB | Output is correct |
11 | Correct | 1 ms | 1408 KB | Output is correct |
12 | Correct | 1 ms | 1152 KB | Output is correct |
13 | Correct | 1 ms | 1408 KB | Output is correct |
14 | Correct | 1 ms | 1152 KB | Output is correct |
15 | Correct | 1 ms | 1152 KB | Output is correct |
16 | Correct | 1 ms | 1408 KB | Output is correct |
17 | Correct | 1 ms | 1024 KB | Output is correct |
18 | Correct | 1 ms | 1536 KB | Output is correct |
19 | Correct | 2 ms | 1664 KB | Output is correct |
20 | Correct | 1 ms | 1152 KB | Output is correct |
21 | Correct | 3 ms | 2944 KB | Output is correct |
22 | Correct | 67 ms | 36984 KB | Output is correct |
23 | Correct | 51 ms | 13944 KB | Output is correct |
24 | Correct | 49 ms | 16632 KB | Output is correct |
25 | Correct | 52 ms | 15352 KB | Output is correct |
26 | Correct | 49 ms | 15992 KB | Output is correct |
27 | Correct | 33 ms | 21624 KB | Output is correct |
28 | Correct | 41 ms | 25976 KB | Output is correct |
29 | Correct | 65 ms | 34060 KB | Output is correct |
30 | Correct | 52 ms | 15480 KB | Output is correct |