Submission #884327

# Submission time Handle Problem Language Result Execution time Memory
884327 2023-12-07T07:03:38 Z AndreiBOTO A Huge Tower (CEOI10_tower) C++14
30 / 100
273 ms 12388 KB
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

const int NMAX=1e6+5;
const int MOD=1e9+7;
vector<int>v;
int best[NMAX];

int main()
{
    int n,d,i,j;
    long long ans=1;
    cin>>n>>d;
    for(i=0;i<n;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(i=0;i<n;i++)
        best[i]=upper_bound(v.begin(),v.end(),v[i]+d)-v.begin();
    for(i=0;i<n;i++)
    {
        ans*=best[i]-i;
        ans%=MOD;
    }
    cout<<ans;
    return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:14:15: warning: unused variable 'j' [-Wunused-variable]
   14 |     int n,d,i,j;
      |               ^
# 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 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 6084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 273 ms 12388 KB Output isn't correct
2 Halted 0 ms 0 KB -