Submission #762681

# Submission time Handle Problem Language Result Execution time Memory
762681 2023-06-21T16:23:39 Z a_aguilo A Huge Tower (CEOI10_tower) C++14
30 / 100
81 ms 14868 KB
#include<bits/stdc++.h>

using namespace std;

int N, D;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	cin >> N >> D;
	long long a[N];
	long long b[N];
	for(int i = 0; i < N; ++i) cin >> a[i];
	sort(a, a + N);
	int left = 0; int right = 0;
	for(int i = 0; i < N; ++i){
		while(right < N and a[right] >= a[i]-D)right++;
		while(a[left] < a[i]-D) left++;
		b[i] = right-left;
	}
	long long dp[N];
	dp[0] = 1;
	for(int i = 1; i < N; ++i){
		dp[i] = dp[i-1]*(b[i] + 1 - (N - i));
		//cout << b[i] << " " << dp[i] << endl;
	}
	cout << dp[N-1] << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 6256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 14868 KB Output isn't correct
2 Halted 0 ms 0 KB -