Submission #1024017

# Submission time Handle Problem Language Result Execution time Memory
1024017 2024-07-15T10:39:21 Z PanosPask A Huge Tower (CEOI10_tower) C++14
65 / 100
95 ms 16204 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 9;

int N, D;
vector<int> a;

// avail[i]: Number of blocks with side length smaller than a[i] and bigger than a[i] + D
vector<int> avail;

// dp[i]: Number of ways to arrange the first i blocks
vector<ll> dp;

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

    a.resize(N);
    avail.resize(N);
    dp.resize(N);

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

    sort(a.begin(), a.end());
    int j = 0;
    for (int i = 0; i < N; i++) {
        while (a[j] + D < a[i]) {
            j++;
        }

        avail[i] = i - j + 1;
    }

    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        dp[i + 1] = dp[i] * avail[i] % MOD;
    }

    printf("%lld\n", dp[N]);

    return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %d", &N, &D);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tower.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1628 KB Output is correct
2 Correct 7 ms 1724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 6776 KB Output is correct
2 Correct 37 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 16204 KB Output is correct
2 Correct 95 ms 15440 KB Output is correct