Submission #546541

#TimeUsernameProblemLanguageResultExecution timeMemory
546541MilosMilutinovicA Huge Tower (CEOI10_tower)C++14
30 / 100
18 ms2316 KiB
#include <stdio.h> #define N 100000 #define MD 1000000007 int n, d, aa[N], bb[N]; long long dp[N]; void sort(int l, int r) { int i, cc0, cc1; if (l >= r) return; int m = (l + r) / 2; sort(l, m); sort(m + 1, r); cc0 = l, cc1 = m + 1; for (i = l; i <= r; i++) if (cc0 > m || (cc1 <= r && aa[cc0] > aa[cc1])) bb[i] = aa[cc1++]; else bb[i] = aa[cc0++]; for (i = l; i <= r; i++) aa[i] = bb[i]; } int main() { int i, j; scanf("%d%d", &n, &d); for (i = 0; i < n; i++) scanf("%d", &aa[i]); sort(0, n - 1); for (i = 0, j = 0; i < n; i++) { while (aa[j] < aa[i] - d) j++; dp[i] = (i == 0 ? 1LL : dp[i - 1]) * (i - j + 1), dp[i] = (dp[i] % MD); } printf("%lld\n", dp[n - 1]); return 0; }

Compilation message (stderr)

tower.cpp: In function 'int main()':
tower.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d%d", &n, &d);
      |  ~~~~~^~~~~~~~~~~~~~~~
tower.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d", &aa[i]);
      |   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...