Submission #439522

# Submission time Handle Problem Language Result Execution time Memory
439522 2021-06-30T07:38:20 Z s_jaskaran_s A Huge Tower (CEOI10_tower) C++17
100 / 100
165 ms 8732 KB
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin>>n>>d;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=1;
    sort(a.rbegin(),a.rend());
    int j=0;
    for(int i=0;i<n;i++){
        if(a[i]-a[j]<=d&&j<n){
            j++;
            i--;
        }
        else{
            ans=(ans*(j-i))%1000000009;
        }
    }
    cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 884 KB Output is correct
2 Correct 12 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3720 KB Output is correct
2 Correct 60 ms 3652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 8732 KB Output is correct
2 Correct 165 ms 8100 KB Output is correct