Submission #936019

# Submission time Handle Problem Language Result Execution time Memory
936019 2024-03-01T01:48:05 Z srivatsav_kannan A Huge Tower (CEOI10_tower) C++14
100 / 100
116 ms 10736 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <bitset>
#include <climits>
#include <valarray>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#define int long long int
#define double long double
#define endl '\n'
#define mod 1000000009
#define inf 2000000000000000000
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree < pair<int,int> ,  nuint_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
void solve(){
    //    ifstream fin("diamond.in");
    //    ofstream fout("diamond.out");
    int n,d; cin >> n >> d;
    int ar[n];
    for (int i = 0; i < n; i++) cin >> ar[i];

    sort(ar, ar+n);
    int prev = 1;
    
    for (int i = 1; i < n; i++){
        int l = 0, r = i;
        while (l < r){
            int mid = (l+r)/2;
            if (ar[mid]+d >= ar[i]) r = mid;
            else l = mid+1;
        }
        int num = i-l;
        prev = ((prev%mod)*((num+1)%mod))%mod;
    }
    cout << prev << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 604 KB Output is correct
2 Correct 8 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 2396 KB Output is correct
2 Correct 39 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 5220 KB Output is correct
2 Correct 116 ms 10736 KB Output is correct