Submission #136747

# Submission time Handle Problem Language Result Execution time Memory
136747 2019-07-26T08:10:17 Z choikiwon A Huge Tower (CEOI10_tower) C++17
100 / 100
175 ms 10616 KB
#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 9;

int N, D;
vector<int> A, B;

int main() {
    scanf("%d %d", &N, &D);

    A.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    sort(A.begin(), A.end());

    B.resize(N);
    int pos = 0;
    for(int i = 0; i < N; i++) {
        while(pos < i && A[pos] + D < A[i]) pos++;
        B[i] = i - pos;
    }

    int ans = 1;
    for(int i = 1; i < N; i++) {
        ans = 1LL * ans * (B[i] + 1) % mod;
    }
    printf("%d", ans);
}

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]
     scanf("%d %d", &N, &D);
     ~~~~~^~~~~~~~~~~~~~~~~
tower.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 744 KB Output is correct
2 Correct 15 ms 1244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 2256 KB Output is correct
2 Correct 69 ms 4656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 143 ms 5232 KB Output is correct
2 Correct 175 ms 10616 KB Output is correct