Submission #387465

#TimeUsernameProblemLanguageResultExecution timeMemory
387465tostesA Huge Tower (CEOI10_tower)C++17
100 / 100
141 ms16412 KiB
#include<bits/stdc++.h> //#include<iostream> //#include<vector> using namespace std; #define _ << ' ' << #define pb push_back #define all(x) begin(x), end(x) #define mp make_pair #define f first #define s second #define sz(x) int((x).size()) using ll = long long; using db = long double; using pl = pair<ll,ll>; using pi = pair<int,int>; using str = string; vector < int > pos[30]; ll mod=1'000'000'000+9; int main(){ ios::sync_with_stdio(false); cin.tie(0); //freopen("diamond.in","r",stdin); //freopen("diamond.out","w",stdout); ll n,d; cin >> n >> d; vector < ll > a(n); for(auto &x: a) cin >> x; sort(all(a)); vector < ll > x(n); int i=n-1, j=n-1; while(j>=0 and i>=0){ while(j-1>=0 and a[j-1]+d>=a[i]) j--; x[i]=i-j; i--; } ll ans=1; for(int i=0; i<n; i++){ ans=(ans*(x[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...