Submission #923994

#TimeUsernameProblemLanguageResultExecution timeMemory
923994NintsiChkhaidzeA Huge Tower (CEOI10_tower)C++17
90 / 100
26 ms7516 KiB
#include <bits/stdc++.h> #define ll long long #define s second #define f first #define pb push_back #define pii pair <int,int> #define left (h<<1),l,(l + r)/2 #define right ((h<<1)|1),(l + r)/2 + 1,r #define int ll using namespace std; const int N = 2e5 + 3,mod = 1e9 + 9; int a[N],c[N]; signed main(){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n,D; cin>>n>>D; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a+1,a+n+1); int r = n + 1; for (int i = n; i >= 1; i--){ while (r - 1 >= 1 && a[i] <= a[r - 1] + D){ --r; } c[i] = max(0LL,i - r); } int ans=1; for (int i= 1; i <= n; i++){ ans = ans * (c[i] + 1) % mod; } cout<<ans<<endl; }
#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...