Submission #985720

#TimeUsernameProblemLanguageResultExecution timeMemory
985720AA_SurelyA Huge Tower (CEOI10_tower)C++14
30 / 100
79 ms2652 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define FOR(i, x, n) for(int i = x; i < n; i++) #define F0R(i, n) FOR(i, 0, n) #define ROF(i, x, n) for(int i = n - 1; i >= x; i--) #define R0F(i, n) ROF(i, 0, n) #define WTF cout << "WTF" << endl #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define F first #define S second #define PB push_back #define EP emplace_back #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x,rend() using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<PII> VPII; typedef vector<PLL> VPLL; const int N = 1e6 + 7; const int INF = 1e9 + 7; const int LOG = 22; const int A = 26; const int SQ = 320; const int MOD = 1e9 + 7; int n, d; int main() { IOS; cin >> n >> d; VI ns(n); F0R(i, n) cin >> ns[i]; sort(ALL(ns)); LL ptr = 0; LL ans = 1; F0R(i, n) { while(ptr < n && ns[ptr] <= ns[i] + d) ptr++; ans = (ans * (ptr - i)) % MOD; } cout << (ans + MOD) % MOD; }
#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...