답안 #288217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288217 2020-09-01T10:17:10 Z Pyqe Skyscraper (JOI16_skyscraper) C++14
100 / 100
158 ms 5504 KB
#include <bits/stdc++.h>

using namespace std;

long long n,d,a[169],dp[2][169][3][1069],dv=1e9+7;

int main()
{
	long long i,j,r,jj,k,z=0;
	
	scanf("%lld%lld",&n,&d);
	if(n==1)
	{
		printf("1\n");
		return 0;
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",a+i);
	}
	sort(a+1,a+n+1);
	for(i=n;i;i--)
	{
		a[i]-=a[i-1];
	}
	dp[0][0][0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(r=0;r<=2;r++)
			{
				k=a[i+1]*(j*2-r);
				for(jj=k;jj<=d;jj++)
				{
					dp[1][j][r][jj]=(dp[0][j-1][r][jj-k]*(j-r)+dp[0][j][r][jj-k]*(j*2-r)+dp[0][j+1][r][jj-k]*j)%dv;
					if(r)
					{
						dp[1][j][r][jj]=(dp[1][j][r][jj]+dp[0][j-1][r-1][jj-k]*(3-r)+dp[0][j][r-1][jj-k]*(3-r))%dv;
					}
				}
			}
		}
		for(j=0;j<=n;j++)
		{
			for(r=0;r<=2;r++)
			{
				for(jj=0;jj<=d;jj++)
				{
					dp[0][j][r][jj]=dp[1][j][r][jj];
					dp[1][j][r][jj]=0;
				}
			}
		}
	}
	for(i=0;i<=d;i++)
	{
		z=(z+dp[0][1][2][i])%dv;
	}
	printf("%lld\n",z);
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%lld%lld",&n,&d);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
skyscraper.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |   scanf("%lld",a+i);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 1 ms 640 KB Output is correct
12 Correct 1 ms 768 KB Output is correct
13 Correct 1 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 1 ms 768 KB Output is correct
17 Correct 1 ms 768 KB Output is correct
18 Correct 1 ms 768 KB Output is correct
19 Correct 1 ms 768 KB Output is correct
20 Correct 1 ms 768 KB Output is correct
21 Correct 2 ms 1408 KB Output is correct
22 Correct 140 ms 4352 KB Output is correct
23 Correct 152 ms 5496 KB Output is correct
24 Correct 136 ms 5376 KB Output is correct
25 Correct 155 ms 5448 KB Output is correct
26 Correct 138 ms 5448 KB Output is correct
27 Correct 52 ms 3960 KB Output is correct
28 Correct 70 ms 4224 KB Output is correct
29 Correct 130 ms 5504 KB Output is correct
30 Correct 158 ms 5376 KB Output is correct