# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57191 |
2018-07-14T08:56:05 Z |
윤교준(#1654) |
Skyscraper (JOI16_skyscraper) |
C++11 |
|
133 ms |
19540 KB |
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int MAXN = 102;
const int MAXL = 1002;
void add(int &a, ll b) { a = ((b+a)%MOD + MOD) % MOD; }
int dp[MAXN][MAXN][MAXL][4];
int A[MAXN];
int N, L, Ans;
int main() {
ios::sync_with_stdio(false);
cin >> N >> L;
for(int i = 1; i <= N; i++) cin >> A[i];
sort(A+1, A+N+1);
if(1 == N) {
puts("1");
return 0;
}
dp[1][1][0][0] = dp[1][1][0][1] = dp[1][1][0][2] = 1;
for(int i = 1; i < N; i++) {
for(int j = 1; j <= i; j++) {
for(int k = 0; k <= L; k++) {
for(int l = 0; l < 4; l++) {
ll ret = dp[i][j][k][l];
if(!ret) continue;
int lc = !!(l&1) + !!(l&2);
int c = (A[i+1] - A[i]) * (j*2 - lc) + k;
if(L < c) continue;
if(!(l&1)) add(dp[i+1][j][c][l|1], ret);
if(!(l&2)) add(dp[i+1][j][c][l|2], ret);
if(!(l&1)) add(dp[i+1][j+1][c][l|1], ret);
if(!(l&2)) add(dp[i+1][j+1][c][l|2], ret);
add(dp[i+1][j+1][c][l], ret * (j+1 - lc));
add(dp[i+1][j][c][l], ret * (j*2 - lc));
if(1 < j) add(dp[i+1][j-1][c][l], ret * (j-1));
}
}
}
}
for(int i = 0; i <= L; i++)
Ans = (Ans + dp[N][1][i][3]) % MOD;
cout << Ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
3 ms |
684 KB |
Output is correct |
6 |
Correct |
3 ms |
812 KB |
Output is correct |
7 |
Correct |
3 ms |
812 KB |
Output is correct |
8 |
Correct |
3 ms |
812 KB |
Output is correct |
9 |
Correct |
3 ms |
876 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
972 KB |
Output is correct |
2 |
Correct |
3 ms |
972 KB |
Output is correct |
3 |
Correct |
3 ms |
1060 KB |
Output is correct |
4 |
Correct |
4 ms |
1060 KB |
Output is correct |
5 |
Correct |
36 ms |
1060 KB |
Output is correct |
6 |
Correct |
3 ms |
1060 KB |
Output is correct |
7 |
Correct |
4 ms |
1060 KB |
Output is correct |
8 |
Correct |
3 ms |
1060 KB |
Output is correct |
9 |
Correct |
3 ms |
1060 KB |
Output is correct |
10 |
Correct |
3 ms |
1060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
3 ms |
684 KB |
Output is correct |
6 |
Correct |
3 ms |
812 KB |
Output is correct |
7 |
Correct |
3 ms |
812 KB |
Output is correct |
8 |
Correct |
3 ms |
812 KB |
Output is correct |
9 |
Correct |
3 ms |
876 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
3 ms |
972 KB |
Output is correct |
12 |
Correct |
3 ms |
972 KB |
Output is correct |
13 |
Correct |
3 ms |
1060 KB |
Output is correct |
14 |
Correct |
4 ms |
1060 KB |
Output is correct |
15 |
Correct |
36 ms |
1060 KB |
Output is correct |
16 |
Correct |
3 ms |
1060 KB |
Output is correct |
17 |
Correct |
4 ms |
1060 KB |
Output is correct |
18 |
Correct |
3 ms |
1060 KB |
Output is correct |
19 |
Correct |
3 ms |
1060 KB |
Output is correct |
20 |
Correct |
3 ms |
1060 KB |
Output is correct |
21 |
Correct |
6 ms |
1508 KB |
Output is correct |
22 |
Correct |
133 ms |
19540 KB |
Output is correct |
23 |
Correct |
88 ms |
19540 KB |
Output is correct |
24 |
Correct |
88 ms |
19540 KB |
Output is correct |
25 |
Correct |
90 ms |
19540 KB |
Output is correct |
26 |
Correct |
76 ms |
19540 KB |
Output is correct |
27 |
Correct |
60 ms |
19540 KB |
Output is correct |
28 |
Correct |
60 ms |
19540 KB |
Output is correct |
29 |
Correct |
101 ms |
19540 KB |
Output is correct |
30 |
Correct |
79 ms |
19540 KB |
Output is correct |