Submission #374735

#TimeUsernameProblemLanguageResultExecution timeMemory
374735wzyA Huge Tower (CEOI10_tower)C++11
100 / 100
143 ms13036 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = (ll) 1e9 + 9; int32_t main(){ int n , d , j = 1; scanf("%d%d" , &n , &d); vector<int> v(n+1); vector<long long> dp(n+1); dp[0] = 1; for(int i = 1; i <= n; i ++){ scanf("%d" , &v[i]); } sort(v.begin() + 1 , v.end()); for(int i = 1; i <= n; i ++){ while(v[i] > v[j] + d) j++; dp[i] = (dp[i-1] * ((ll) i-j+1))%mod; } printf("%lld\n" , dp[n]); }

Compilation message (stderr)

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