This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <fstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
// ofstream fout ("split.out");
// ifstream fin ("split.in");
int main(){
int n,d;
cin>>n>>d;
int array[n];
int barray[n]={0};
for(int i=0;i<n;i++){
cin>>array[i];
}
sort(array,array+n);
int pointeri=n-1;
int pointerj=n-2;
while(pointerj>=0){
if(pointerj==0){
if(pointeri==1){
if(array[pointerj]+d<array[pointeri]){
pointerj--;
}
else{
barray[pointeri]++;
pointerj--;
}
}
else{
if(array[pointerj]+d<array[pointeri]){
pointeri--;
pointerj=pointeri-1;
}
else{
barray[pointeri]++;
pointeri--;
pointerj=pointeri-1;
}
}
}
else{
if(array[pointerj]+d<array[pointeri]){
pointeri--;
pointerj=pointeri-1;
}
else{
barray[pointeri]++;
pointerj--;
}
}
}
long long product=1;
for(int i=0;i<n;i++){
product*=(barray[i]+1);
}
cout<<product%1000000009;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |