Submission #44598

#TimeUsernameProblemLanguageResultExecution timeMemory
44598choikiwonSkyscraper (JOI16_skyscraper)C++17
15 / 100
371 ms491152 KiB
#include<bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int offset = 1000; int N, L; int A[102]; int cc[102][102][3010][2][2]; int dp(int n, int d, int sum, int s, int e) { if(sum >= 3010) return 0; if(n == N) return !d && sum <= L + offset && s && e; int &ret = cc[n][d][sum][s][e]; if(ret != -1) return ret; int l = d; int r = d + e - s; if(n && l <= 0 && r <= 0) return ret = 0; ret = 0; if(!s) { ret += dp(n + 1, d + 1, A[n] + sum + 2 * (A[n + 1] - A[n]) * (d + 1), 1, e); ret %= mod; if(r) { ret += 1LL * (n == N - 1? r : r - e) * dp(n + 1, d, A[n] + sum + 2 * (A[n + 1] - A[n]) * d, 1, e) % mod; ret %= mod; } } if(!e) { ret += dp(n + 1, d, -A[n] + sum + 2 * (A[n + 1] - A[n]) * d, s, 1); ret %= mod; if(l) { ret += 1LL * (n == N - 1? l : l - s) * dp(n + 1, d - 1, -A[n] + sum + 2 * (A[n + 1] - A[n]) * (d - 1), s, 1) % mod; ret %= mod; } } if(l) { ret += 1LL * l * dp(n + 1, d, sum + 2 * (A[n + 1] - A[n]) * d, s, e) % mod; ret %= mod; if(s && !e) { ret += 1LL * r * dp(n + 1, d - 1, sum + 2 * (A[n + 1] - A[n]) * (d - 1), s, e) % mod; ret %= mod; } if(r) { ret += 1LL * min(l, r) * (n == N - 1? r : r - 1) % mod * dp(n + 1, d - 1, sum + 2 * (A[n + 1] - A[n]) * (d - 1), s, e) % mod; ret %= mod; } } if(r) { ret += 1LL * r * dp(n + 1, d, sum + 2 * (A[n + 1] - A[n]) * d, s, e) % mod; ret %= mod; } ret += dp(n + 1, d + 1, sum + 2 * (A[n + 1] - A[n]) * (d + 1), s, e); ret %= mod; return ret; } int main() { scanf("%d %d", &N, &L); for(int i = 0; i < N; i++) { scanf("%d", &A[i]); } sort(A, A + N); memset(cc, -1, sizeof(cc)); printf("%d", dp(0, 0, offset, 0, 0)); }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:62:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &N, &L);
     ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:65:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...