Submission #424633

# Submission time Handle Problem Language Result Execution time Memory
424633 2021-06-12T08:21:23 Z aris12345678 A Huge Tower (CEOI10_tower) C++14
100 / 100
150 ms 8096 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 1000005;
const int mod = 1e9+9;
int blocks[mxN];

int main() {
    int n, d;
    scanf("%d %d", &n, &d);
    for(int i = 0; i < n; i++)
        scanf("%d", &blocks[i]);
    sort(blocks, blocks+n);
    int i = 0, j = 0;
    long long ans = 1;
    while(i < n) {
        while(j < n-1 && blocks[j+1]-d <= blocks[i])
            j++;
        ans = (ans*(j-i+1))%mod;
        i++;
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &n, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tower.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d", &blocks[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 460 KB Output is correct
2 Correct 12 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 1256 KB Output is correct
2 Correct 69 ms 3780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 2680 KB Output is correct
2 Correct 150 ms 8096 KB Output is correct