Submission #464702

#TimeUsernameProblemLanguageResultExecution timeMemory
464702jackkkkA Huge Tower (CEOI10_tower)C++11
30 / 100
1095 ms11172 KiB
/* Problem title: A Huge Tower Problem link: https://oj.uz/problem/view/CEOI10_tower */ #include <stdio.h> #include <iostream> #include <string> #include <vector> #include <queue> #include <map> #include <array> #include <deque> #include <unordered_map> #include <unordered_set> #include <set> #include <algorithm> #include <stdlib.h> #include <math.h> #include <list> #include <float.h> #include <climits> #include <cmath> using namespace std; #define _USE_MATH_DEFINES #define F first #define S second #define MP make_pair typedef long long LL; typedef pair<long long, long long> pii; typedef pair<LL, LL> pll; void quit(){ cout.flush(); exit(0); } LL NM=10e9+9; LL n, d; vector <LL> nums; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d; nums.resize(n); for(LL i = 0; i < n; i++){ cin >> nums[i]; } sort(nums.begin(), nums.end()); LL ans = 1; for(int i = 0; i < n; i++){ int p=0; for(int j = 0; j <= i; j++){ if(nums[i]-nums[j]<=d){ p++; } } ans*=p; ans %=NM; } /* long long r = 1; long long ans = 1; for(long long l = 0; l < n; l++){ while(r<n && nums[r]-nums[l]<=d){ ans *= r-l+1; ans %= NM; r++; } } */ cout << ans << "\n"; quit(); }
#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...