Submission #480393

#TimeUsernameProblemLanguageResultExecution timeMemory
480393nehasaneA Huge Tower (CEOI10_tower)C++14
0 / 100
290 ms2636 KiB
#include <bits/stdc++.h> using namespace std; long long factorial(int s){ long long ans = 1; for (int i = s; i >= 1; i--) ans *= i; return ans; } int main() { int n, d; cin >> n >> d; vector <int> blocks(n); for (int i = 0; i < n; i++) cin >> blocks[i]; sort(begin(blocks), end(blocks)); long long ans = 1; int l = 0, r = 0; while (r < n){ if (blocks[l] + d < blocks[r]){ ans *= factorial(r-l); if (blocks[r] + d < blocks[r+1]) l = r-1; else l = r; } r++; } cout << ans * factorial(r-l) << '\n'; }
#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...