Submission #419947

# Submission time Handle Problem Language Result Execution time Memory
419947 2021-06-07T19:14:54 Z Haidara A Huge Tower (CEOI10_tower) C++17
100 / 100
135 ms 5068 KB
/*
ID: haidara
LANG: C++17
PROB: diamond
*/
#include<bits/stdc++.h>
#pragma GCC optimize("O1")
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
#define per(i,x,n) for(int i=x;i>n;i--)
#define ROF(i,x) for(int i=x;i>=0;i--)
#define v(i) vector< i >
#define p(i,j) pair< i , j >
#define pii pair<int,int>
#define m(i,j) map< i , j >
#define pq(i) priority_queue< i >
#define ff first
#define all(x) x.begin(),x.end()
#define ss second
#define pp push_back
using namespace std;
const int inf=1LL<<62LL;
const int mod=1e9+9;
const int maxn=200200;
signed main()
{
    //freopen("diamond.in","r",stdin);
    //freopen("diamond.out","w",stdout);
    fast;
    int n,d;
    cin>>n>>d;
    v(int)a(n);
    FOR(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int r=0,sol=1,inx=0;
    FOR(i,n)
    {
        while(r<n-1&&a[r+1]-a[i]<=d)
            r++;
        sol=(sol*(r-i+1))%mod;
    }
    cout<<sol;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:37:19: warning: unused variable 'inx' [-Wunused-variable]
   37 |     int r=0,sol=1,inx=0;
      |                   ^~~
# 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 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 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 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 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 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 588 KB Output is correct
2 Correct 11 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 2256 KB Output is correct
2 Correct 58 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 5068 KB Output is correct
2 Correct 135 ms 5068 KB Output is correct