# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
199911 | 2020-02-04T00:35:49 Z | CaroLinda | Skyscraper (JOI16_skyscraper) | C++14 | 483 ms | 6780 KB |
#include <bits/stdc++.h> const int MOD = 1e9+7 ; const int MAXN = 105 ; const int MAXL = 1005 ; using namespace std ; int N , L ; int F[MAXN] , idx[MAXN] ; long long dp[2][2][MAXN][2][MAXL] ; inline void f(long long &x, long long y) { x = (x+y) % MOD ; } int main() { scanf("%d%d", &N , &L ) ; for(int i = 1 ; i <= N ; i++ ) scanf("%d", &F[i] ) ; sort(F+1, F+1+N ) ; if( N == 1 ) { printf("1\n") ; return 0 ; } for(int i = 1 ; i<= N+1 ; i++ ) idx[i] = i%2 ; for(int i = N ; i > 0 ; i-- ) for(int lef = 0 ; lef < 2 ; lef++ ) for(int c = 0 ; c <= N ; c++ ) for(int rig = 0 ; rig < 2 ; rig ++ ) for(int cost = 0 ; cost <= L ; cost ++ ) { long long &x = dp[ idx[i] ][lef][c][rig][cost] ; x = 0 ; int new_cost = cost + ( F[i] - F[i-1] ) * ( 2*c + lef + rig ) ; if( new_cost > L ) continue ; int id = idx[i+1] ; if( i == N ) { x = ( c == 0 ? 1 : 0 ) ; continue ; } if( c > 0 ) { f( x , dp[id][1][c-1][rig][new_cost] * c ) ; f( x , dp[id][lef][c-1][1][new_cost] * c ) ; f( x , dp[id][lef][c-1][rig][new_cost] * c * (c-1) ) ; } f( x , dp[id][1][c][rig][ new_cost ] ) ; //soh coloquei na esquerda f( x , dp[id][lef][c][1][ new_cost ] ) ; f( x , dp[id][lef][c+1][rig][ new_cost ] ) ; f( x , dp[id][lef][c][rig][ new_cost ] * 2 * c ) ; } printf("%lld\n" , dp[1][0][0][0][0]) ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 504 KB | Output is correct |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 7 ms | 888 KB | Output is correct |
6 | Correct | 7 ms | 888 KB | Output is correct |
7 | Correct | 6 ms | 760 KB | Output is correct |
8 | Correct | 5 ms | 632 KB | Output is correct |
9 | Correct | 9 ms | 888 KB | Output is correct |
10 | Correct | 5 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 764 KB | Output is correct |
2 | Correct | 6 ms | 888 KB | Output is correct |
3 | Correct | 6 ms | 888 KB | Output is correct |
4 | Correct | 6 ms | 892 KB | Output is correct |
5 | Correct | 6 ms | 888 KB | Output is correct |
6 | Correct | 6 ms | 892 KB | Output is correct |
7 | Correct | 5 ms | 888 KB | Output is correct |
8 | Correct | 5 ms | 892 KB | Output is correct |
9 | Correct | 6 ms | 888 KB | Output is correct |
10 | Correct | 6 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 504 KB | Output is correct |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 7 ms | 888 KB | Output is correct |
6 | Correct | 7 ms | 888 KB | Output is correct |
7 | Correct | 6 ms | 760 KB | Output is correct |
8 | Correct | 5 ms | 632 KB | Output is correct |
9 | Correct | 9 ms | 888 KB | Output is correct |
10 | Correct | 5 ms | 632 KB | Output is correct |
11 | Correct | 6 ms | 764 KB | Output is correct |
12 | Correct | 6 ms | 888 KB | Output is correct |
13 | Correct | 6 ms | 888 KB | Output is correct |
14 | Correct | 6 ms | 892 KB | Output is correct |
15 | Correct | 6 ms | 888 KB | Output is correct |
16 | Correct | 6 ms | 892 KB | Output is correct |
17 | Correct | 5 ms | 888 KB | Output is correct |
18 | Correct | 5 ms | 892 KB | Output is correct |
19 | Correct | 6 ms | 888 KB | Output is correct |
20 | Correct | 6 ms | 888 KB | Output is correct |
21 | Correct | 7 ms | 1784 KB | Output is correct |
22 | Correct | 483 ms | 5368 KB | Output is correct |
23 | Correct | 440 ms | 6648 KB | Output is correct |
24 | Correct | 425 ms | 6648 KB | Output is correct |
25 | Correct | 462 ms | 6776 KB | Output is correct |
26 | Correct | 404 ms | 6648 KB | Output is correct |
27 | Correct | 164 ms | 5240 KB | Output is correct |
28 | Correct | 222 ms | 5496 KB | Output is correct |
29 | Correct | 430 ms | 6780 KB | Output is correct |
30 | Correct | 463 ms | 6776 KB | Output is correct |