Submission #287527

# Submission time Handle Problem Language Result Execution time Memory
287527 2020-08-31T18:58:12 Z PeppaPig A Huge Tower (CEOI10_tower) C++14
100 / 100
178 ms 8952 KB
#include <bits/stdc++.h>

#define long long long

using namespace std;

const int N = 1e6 + 5;
const int M = 1e9 + 9;

int n, d, A[N];
long ans = 1;

int main() {
    scanf("%d %d", &n, &d);
    for(int i = 1; i <= n; i++) scanf("%d", A + i);

    sort(A + 1, A + n + 1);
    for(int i = 1, j = 0; i <= n; i++) {
        while(j + 1 < i && A[j + 1] + d < A[i])
            ++j;
        ans = ans * (i - j) % M;
    }
    printf("%lld\n", ans);

    return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d %d", &n, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tower.cpp:15:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     for(int i = 1; i <= n; i++) scanf("%d", A + i);
      |                                 ~~~~~^~~~~~~~~~~~~
# 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 384 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 384 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 256 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 256 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 0 ms 256 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 288 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 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1024 KB Output is correct
2 Correct 14 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 3704 KB Output is correct
2 Correct 70 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 8952 KB Output is correct
2 Correct 178 ms 8248 KB Output is correct