Submission #154818

# Submission time Handle Problem Language Result Execution time Memory
154818 2019-09-25T01:07:03 Z arnold518 A Huge Tower (CEOI10_tower) C++14
100 / 100
187 ms 8172 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e6;
const ll MOD = 1e9+9;

int N, D;
int A[MAXN+10];
ll ans=1;

int main()
{
    int i, j;

    scanf("%d%d", &N, &D);
    for(i=1; i<=N; i++) scanf("%d", &A[i]);
    sort(A+1, A+N+1);

    for(i=1; i<=N; i++) ans*=A+i-lower_bound(A+1, A+i, A[i]-D)+1, ans%=MOD;
    printf("%lld", ans);
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:17:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
tower.cpp:19: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:20:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &A[i]);
                         ~~~~~^~~~~~~~~~~~~
# 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 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 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 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 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 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 380 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 16 ms 1048 KB Output is correct
2 Correct 15 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 3680 KB Output is correct
2 Correct 67 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 3832 KB Output is correct
2 Correct 187 ms 8172 KB Output is correct