# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57157 | 2018-07-14T07:27:52 Z | 김세빈(#1653) | Skyscraper (JOI16_skyscraper) | C++11 | 4 ms | 1252 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; ll D[2][111][3][1010]; ll A[111]; ll n, k, ans; int main() { int i, j, l, x, t; scanf("%lld%lld", &n, &k); if(n == 1){ printf("1\n"); return 0; } for(i=1;i<=n;i++){ scanf("%lld", A+i); } sort(A+1, A+n+1); D[0][0][0][0] = 1; for(i=1;i<n;i++){ for(j=0;j<=i;j++){ for(l=0;l<=k;l++){ // endpoints t = l + (A[i] - A[i-1]) * j * 2; if(t <= k){ if(j){ D[i&1][j-1][1][t] = (D[i&1][j-1][1][t] + D[~i&1][j][0][l] * (ll)2) % mod; } D[i&1][j][1][t] = (D[i&1][j][1][t] + D[~i&1][j][0][l] * (ll)2) % mod; } t = l + (A[i] - A[i-1]) * (j * 2 + 1); if(t <= k){ if(j){ D[i&1][j-1][2][t] = (D[i&1][j-1][2][t] + D[~i&1][j][1][l]) % mod; D[i&1][j-1][1][t] = (D[i&1][j-1][1][t] + D[~i&1][j][1][l]) % mod; } D[i&1][j][2][t] = (D[i&1][j][2][t] + D[~i&1][j][1][l]) % mod; D[i&1][j][1][t] = (D[i&1][j][1][t] + D[~i&1][j][1][l]) % mod; } t = l + (A[i] - A[i-1]) * (j * 2 + 2); if(t <= k){ if(j){ D[i&1][j-1][2][t] = (D[i&1][j-1][2][t] + D[~i&1][j][2][l] * (ll)2) % mod; } D[i&1][j][2][t] = (D[i&1][j][2][t] + D[~i&1][j][2][l] * (ll)2) % mod; } for(x=0;x<3;x++){ t = l + (A[i] - A[i-1]) * (j * 2 + x); if(t > k) continue; // new group D[i&1][j+1][x][t] = (D[i&1][j+1][x][t] + D[~i&1][j][x][l] * (ll)(j + 1)) % mod; // merge two groups if(j > 1){ D[i&1][j-1][x][t] = (D[i&1][j-1][x][t] + D[~i&1][j][x][l] * (ll)(j - 1)) % mod; } // group endpoints D[i&1][j][x][t] = (D[i&1][j][x][t] + D[~i&1][j][x][l] * (ll)2 * j) % mod; D[~i&1][j][x][l] = 0; } } } } for(i=0;i<=k;i++){ t = i + (A[n] - A[n-1]) * 2; if(t <= k) ans = (ans + D[~n&1][0][2][i]) % mod; t = i + (A[n] - A[n-1]); if(t <= k) ans = (ans + D[~n&1][0][1][i]) % mod; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 600 KB | Output is correct |
3 | Correct | 2 ms | 656 KB | Output is correct |
4 | Correct | 3 ms | 772 KB | Output is correct |
5 | Correct | 4 ms | 1076 KB | Output is correct |
6 | Incorrect | 3 ms | 1252 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1252 KB | Output is correct |
2 | Incorrect | 3 ms | 1252 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 600 KB | Output is correct |
3 | Correct | 2 ms | 656 KB | Output is correct |
4 | Correct | 3 ms | 772 KB | Output is correct |
5 | Correct | 4 ms | 1076 KB | Output is correct |
6 | Incorrect | 3 ms | 1252 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |