Submission #435182

#TimeUsernameProblemLanguageResultExecution timeMemory
435182vbeeA Huge Tower (CEOI10_tower)C++14
100 / 100
143 ms11216 KiB
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define ii pair<int,int> #define vii vector<ii> #define vi vector<int> #define fi first #define se second #define TASK "" #define pb push_back #define MASK(i) (1 << (i)) #define BIT(x, i) ((x >> (i)) & 1) using namespace std; typedef long long ll; const int oo = 1e9+9; int msb(int x) { union { double a; int b[2]; }; a = x; return (b[1] >> 20) - 1023; } ll nxt(){ ll a; cin >> a; return a; } ll sqr(ll x){ return x * x % oo; } const int N = 1e6 + 7; ll n, a[N], d; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> d; for (int i = 1; i <= n; i++){ cin >> a[i]; } sort(a + 1, a + 1 + n); int r = 1; ll res = 1; for (int l = 1; l <= n; l++){ while (r < n && a[r + 1] - a[l] <= d){ r++; } res = res * (r - l + 1) % oo; } cout << res; return 0; }
#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...