Submission #297036

#TimeUsernameProblemLanguageResultExecution timeMemory
297036arnold518Skyscraper (JOI16_skyscraper)C++14
20 / 100
975 ms400560 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 14; const ll MOD = 1e9+7; int N, L, A[MAXN+10]; ll dp[(1<<MAXN)][MAXN][110]; ll solve(int mask, int bef, int sum) { if(sum>L) return 0; if(mask==((1<<N)-1)) return 1; ll &ret=dp[mask][bef][sum]; if(ret!=-1) return ret; ret=0; for(int i=0; i<N; i++) { if(mask&(1<<i)) continue; ret+=solve(mask|(1<<i), i, sum+abs(A[i]-A[bef])); ret%=MOD; } return ret; } int main() { scanf("%d%d", &N, &L); for(int i=0; i<N; i++) scanf("%d", &A[i]); memset(dp, -1, sizeof(dp)); ll ans=0; for(int i=0; i<N; i++) ans=(ans+solve((1<<i), i, 0))%MOD; printf("%lld\n", ans); }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |  scanf("%d%d", &N, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~
skyscraper.cpp:34:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |  for(int i=0; i<N; i++) scanf("%d", &A[i]);
      |                         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...