Submission #301091

#TimeUsernameProblemLanguageResultExecution timeMemory
301091evpipisA Huge Tower (CEOI10_tower)C++11
100 / 100
181 ms8824 KiB
#include <bits/stdc++.h> using namespace std; const int len = 1e6+5, mod = 1e9+9; int arr[len]; int mul(int a, int b){ return (a*1LL*b)%mod; } int main(){ int n, k; scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", &arr[i]); assert(n < len); sort(arr, arr+n); int ans = 1; for (int i = 0, j = 0; i < n; i++){ while (arr[i] > arr[j]+k) j++; ans = mul(ans, i-j+1); } printf("%d\n", ans); return 0; }

Compilation message (stderr)

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