Submission #287527

#TimeUsernameProblemLanguageResultExecution timeMemory
287527PeppaPigA Huge Tower (CEOI10_tower)C++14
100 / 100
178 ms8952 KiB
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 1e6 + 5; const int M = 1e9 + 9; int n, d, A[N]; long ans = 1; int main() { scanf("%d %d", &n, &d); for(int i = 1; i <= n; i++) scanf("%d", A + i); sort(A + 1, A + n + 1); for(int i = 1, j = 0; i <= n; i++) { while(j + 1 < i && A[j + 1] + d < A[i]) ++j; ans = ans * (i - j) % M; } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

tower.cpp: In function 'int main()':
tower.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d %d", &n, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tower.cpp:15:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     for(int i = 1; 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...
#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...