Submission #597637

#TimeUsernameProblemLanguageResultExecution timeMemory
597637gary4988A Huge Tower (CEOI10_tower)C++17
100 / 100
324 ms8772 KiB
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 9; int main () { // freopen("tower.in", "r", stdin); int n, d; cin >> n >> d; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int r = n-1, l = n-1, sol = 1; // all pointers start at right end, l move first for (int r = n-1; r > 0; r--) { while (l >= 0 && a[r] - a[l] <= d) { l--; } // at this point, (l, r] int b = r - l; sol = (sol * 1LL * b) % MOD; } cout << sol << '\n'; }

Compilation message (stderr)

tower.cpp: In function 'int main()':
tower.cpp:17:6: warning: unused variable 'r' [-Wunused-variable]
   17 |  int r = n-1, l = n-1, sol = 1;   // all pointers start at right end, l move first
      |      ^
#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...