Submission #728713

# Submission time Handle Problem Language Result Execution time Memory
728713 2023-04-22T22:45:30 Z benjaminguo A Huge Tower (CEOI10_tower) C++14
100 / 100
312 ms 8728 KB
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <climits>
#include <queue>

using namespace std;

int ans[26][1500];

int main()
{
    int n;
    int d;
    int r = 0;
    int sol = 1;
    
    cin >> n;
    cin >> d;
    
    vector<int> ar(n);
    
    for (int i = 0; i < n; i++)
    {
        cin >> ar[i];
    }
    
    sort(ar.begin(), ar.end());
    
    for (int l = 0; l < n; l++)
    {
        while (r < n - 1 && ar[r + 1] - ar[l] <= d)
        {
            r++;
        }
        
        int dist = r - l + 1;
        
        sol = (sol * 1LL * dist) % 1000000009;
    }
    
    cout << sol;
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 980 KB Output is correct
2 Correct 24 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 3688 KB Output is correct
2 Correct 132 ms 3700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 312 ms 8728 KB Output is correct
2 Correct 298 ms 8076 KB Output is correct