Submission #486399

# Submission time Handle Problem Language Result Execution time Memory
486399 2021-11-11T14:59:41 Z Rainbowbunny A Huge Tower (CEOI10_tower) C++17
100 / 100
112 ms 8772 KB
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 9;

int Mul(int x, int y)
{
    return 1ll * x * y % mod;
}

int n, d;
vector <int> Arr;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> d;
    Arr.resize(n);
    for(auto &x : Arr)
    {
        cin >> x;
    }
    sort(Arr.begin(), Arr.end());
    int pt = 0, ans = 1;
    for(int i = 0; i < Arr.size(); i++)
    {
        while(pt + 1 < (int)Arr.size() and Arr[pt + 1] <= Arr[i] + d)
        {
            pt++;
        }
        ans = Mul(ans, pt - i + 1);
    }
    cout << ans << '\n';
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < Arr.size(); i++)
      |                    ~~^~~~~~~~~~~~
# 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 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 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 1 ms 316 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 256 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 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 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 10 ms 972 KB Output is correct
2 Correct 10 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 3708 KB Output is correct
2 Correct 41 ms 3660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 8772 KB Output is correct
2 Correct 112 ms 8104 KB Output is correct