Submission #202267

# Submission time Handle Problem Language Result Execution time Memory
202267 2020-02-15T00:29:35 Z Segtree Skyscraper (JOI16_skyscraper) C++14
15 / 100
1384 ms 198008 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll n,L,a[14];
ll dp[(1<<14)][14][110];
int main(){
    cin>>n>>L;
    if(n>14)return 0;
    rep(i,n)cin>>a[i];
    rep(s,(1<<n))rep(x,n)rep(l,110)dp[s][x][l]=0;
    rep(i,n)dp[(1<<i)][i][0]=1;
    rep(s,(1<<n))rep(x,n)rep(l,110){
	rep(y,n)if(!(s&(1<<y))){
	    if(l+abs(a[x]-a[y])<110){
		mad(dp[s+(1<<y)][y][l+abs(a[x]-a[y])],dp[s][x][l]);
	    }
	}
    }
    ll ans=0;
    rep(x,n)rep(l,L+1)mad(ans,dp[(1<<n)-1][x][l]);
    cout<<ans<<endl;
}


# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 888 KB Output is correct
5 Incorrect 9 ms 3064 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 268 ms 49784 KB Output is correct
2 Correct 1179 ms 197872 KB Output is correct
3 Correct 1384 ms 197876 KB Output is correct
4 Correct 1123 ms 197880 KB Output is correct
5 Correct 1064 ms 197880 KB Output is correct
6 Correct 1231 ms 197880 KB Output is correct
7 Correct 1328 ms 198008 KB Output is correct
8 Correct 1311 ms 197868 KB Output is correct
9 Correct 1317 ms 197880 KB Output is correct
10 Correct 1157 ms 197880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 888 KB Output is correct
5 Incorrect 9 ms 3064 KB Output isn't correct
6 Halted 0 ms 0 KB -