# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
649359 | 2022-10-10T05:27:45 Z | ToroTN | Skyscraper (JOI16_skyscraper) | C++14 | 347 ms | 79644 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long ll n,a[105],dp[105][105][1005][3],len,ans,cost; void sum(ll a,ll b) { a+=b; a%=1000000007; } ll md(ll a) {return (a+1000000007)%1000000007;} int main() { scanf("%lld%lld",&n,&len); for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); } if(n==1) { printf("1\n"); return 0; } sort(a+1,a+n+1); /*for(int i=1;i<=n;i++) { printf("%d ",a[i]); } printf("\n");*/ dp[1][1][0][0]=1; dp[1][1][0][1]=2; for(int i=1;i<n;i++) { for(int j=1;j<=i;j++) { for(int k=0;k<=len;k++) { for(int l=0;l<=2;l++) { cost=md(md((2*(a[i+1]-a[i])*j)-(a[i+1]-a[i])*l)); if(k+cost>len)continue; for(int c=-1;c<=1;c++) { if(j+c>=1) { if(c==0) { dp[i+1][j+c][k+cost][l]+=md(md(dp[i][j][k][l]*(j-1))*2); }else { dp[i+1][j+c][k+cost][l]+=md(dp[i][j][k][l]*(j-1)); } dp[i+1][j+c][k+cost][l]%=1000000007; if(c>=0) { dp[i+1][j+c][k+cost][l]+=md(dp[i][j][k][l]*(2-l)); dp[i+1][j+c][k+cost][l]%=1000000007; } } } if(l<=1) { for(int c=0;c<=1;c++) { dp[i+1][j+c][k+cost][l+1]+=md(dp[i][j][k][l]*(2-l)); dp[i+1][j+c][k+cost][l+1]%=1000000007; } } } } } } //printf("%d\n",dp[2][2][2][0]); for(int i=0;i<=len;i++) { ans+=dp[n][1][i][2]; ans%=1000000007; } printf("%lld\n",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 852 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 432 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 3 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 724 KB | Output is correct |
2 | Correct | 1 ms | 724 KB | Output is correct |
3 | Correct | 1 ms | 852 KB | Output is correct |
4 | Correct | 1 ms | 724 KB | Output is correct |
5 | Correct | 2 ms | 852 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 724 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 1 ms | 852 KB | Output is correct |
10 | Correct | 1 ms | 724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 852 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 432 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 3 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 724 KB | Output is correct |
12 | Correct | 1 ms | 724 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 2 ms | 852 KB | Output is correct |
16 | Correct | 2 ms | 852 KB | Output is correct |
17 | Correct | 1 ms | 724 KB | Output is correct |
18 | Correct | 1 ms | 852 KB | Output is correct |
19 | Correct | 1 ms | 852 KB | Output is correct |
20 | Correct | 1 ms | 724 KB | Output is correct |
21 | Correct | 4 ms | 3256 KB | Output is correct |
22 | Correct | 287 ms | 67192 KB | Output is correct |
23 | Correct | 314 ms | 78540 KB | Output is correct |
24 | Correct | 291 ms | 76908 KB | Output is correct |
25 | Correct | 340 ms | 79380 KB | Output is correct |
26 | Correct | 287 ms | 74240 KB | Output is correct |
27 | Correct | 122 ms | 42152 KB | Output is correct |
28 | Correct | 142 ms | 48828 KB | Output is correct |
29 | Correct | 259 ms | 74636 KB | Output is correct |
30 | Correct | 347 ms | 79644 KB | Output is correct |