답안 #101163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101163 2019-03-17T07:23:33 Z autumn_eel Skyscraper (JOI16_skyscraper) C++14
15 / 100
296 ms 90972 KB
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int dp[1<<14][14][101];
int a[14];

int main(){
	int n,L;cin>>n>>L;
	if(n>14)abort();
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)dp[1<<i][i][0]=1;
	rep(i,1<<n)rep(j,n){
		if(!(i>>j&1))continue;
		rep(k,L+1){
			if(dp[i][j][k]==0)continue;
			rep(t,n){
				if(i>>t&1)continue;
				if(abs(a[t]-a[j])+k<=L){
					(dp[i|1<<t][t][abs(a[t]-a[j])+k]+=dp[i][j][k])%=MOD;
				}
			}
		}
	}
	int ans=0;
	rep(i,n)rep(j,L+1)(ans+=dp[(1<<n)-1][i][j])%=MOD;
	cout<<ans<<endl;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:15:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  rep(i,n)scanf("%d",&a[i]);
          ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Incorrect 7 ms 1868 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 22876 KB Output is correct
2 Correct 142 ms 89980 KB Output is correct
3 Correct 288 ms 90940 KB Output is correct
4 Correct 144 ms 89592 KB Output is correct
5 Correct 131 ms 89768 KB Output is correct
6 Correct 265 ms 90968 KB Output is correct
7 Correct 132 ms 89476 KB Output is correct
8 Correct 232 ms 90972 KB Output is correct
9 Correct 296 ms 90948 KB Output is correct
10 Correct 147 ms 88632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Incorrect 7 ms 1868 KB Output isn't correct
6 Halted 0 ms 0 KB -