Submission #388210

# Submission time Handle Problem Language Result Execution time Memory
388210 2021-04-10T14:30:50 Z Jisan_1040 A Huge Tower (CEOI10_tower) C++14
100 / 100
134 ms 10692 KB
//Bismillahir Rahman-ir Rahim
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include<cstdio>
#include<cstring>
#include<string>
#include<stdlib.h>
#include<iomanip>

#define PI acos(-1)
#define F first
#define S second
#define debug(x)  cout<<'>'<<#x<<":"<<x<<endl
#define tara ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define Y printf("YES\n")
#define N printf("NO\n")
#define ll long long
#define lll __int128
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<long,long>
#define eb emplace_back
#define pb push_back
#define sc scanf
#define pf printf
#define endl '\n'
#define INF 1<<30
#define ll_INF 1LL<<62

const int M=1e5;


using namespace std ;


int main() {
	tara ;
	ll n, d, i, j;
	cin>>n>>d ;
    ll a[n+1] ;
	for(i=1; i<=n; i++)cin>>a[i] ;

	sort(a+1, a+n+1);
	ll st=1, ans=1;
	for(i=2; i<=n; i++) {
		while(st <= n && a[st]+d < a[i]) ++st;
            //cout<<i<<" "<<st<<endl ;
            ans= (ans*(i-st+1) % 1000000009);
	}
	cout<<ans<<endl;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:49:14: warning: unused variable 'j' [-Wunused-variable]
   49 |  ll n, d, i, j;
      |              ^
# 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 208 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 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 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 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 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 588 KB Output is correct
2 Correct 10 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 2248 KB Output is correct
2 Correct 51 ms 4644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 5028 KB Output is correct
2 Correct 134 ms 10692 KB Output is correct